Forum Moderators: coopster
If you want a more integrated approach then use ajax to validate everything with php.
You could check that the first name contains only letters using the function
if ([url=http://uk3.php.net/manual/en/function.preg-match.php]preg_match[/url]('%[a-z]+%i', $fname)) {
// name is ok
}
else {
// not ok
}
<edit>
added the link to preg_match so you can check it out :)
[edited by: PHP_Chimp at 8:17 pm (utc) on Dec. 22, 2007]
As for the javascript validation it is really only there for the convenience of the user. javascript allows the user to know right away if there is a problem with their form input so that they don't have to submit the form first to find out; however some browsers may not have javascript enabled in which case it would not do any validation if you were to only have that client-side validation present.
Ajax is redundant, however it helps to keep your customers happy, as they get immediate feedback about the validity of there entries.
However NEVER just javascript validate, as people can turn that off, then you have no validation.