JavaScript and PHP Validation and Error Handling CHAPTER 17
Validating User Input with JavaScript JavaScript validation should be considered an assistance more to your users than to your websites hackers can quite easily simulate your web forms and submit any data of their choosing some users disable JavaScript
The validate.html Document (Part One) inputs being requested will be forename, surname, username, password, age, and address Example A form with JavaScript validation this form will display correctly but will not self-validate, because the main validation functions have not yet been added
The validate.html Document (Part Two) a set of six functions that do the actual form field validation Example Part two of the JavaScript validation form
Regular Expressions regular expressions, which are supported by both JavaScript and PHP Matching Through Metacharacters Every regular expression must be enclosed in slashes. Within these slashes, certain characters have special meanings; they are called metacharacters
Fuzzy Character Matching The dot (.) is particularly useful A simple way to do so is: / /
Grouping Through Parentheses Character Classes Indicating a Range Negation Some More Complicated Examples
Summary of Metacharacters Table Regular expression metacharacters Table Some example regular expressions General Modifiers Using Regular Expressions in JavaScript Using Regular Expressions in PHP
Redisplaying a Form After PHP Validation Example The adduser.php program