Presentation is loading. Please wait.

Presentation is loading. Please wait.

JavaScript and PHP Validation and Error Handling CHAPTER 17.

Similar presentations


Presentation on theme: "JavaScript and PHP Validation and Error Handling CHAPTER 17."— Presentation transcript:

1 JavaScript and PHP Validation and Error Handling CHAPTER 17

2 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

3 The validate.html Document (Part One)  inputs being requested will be forename, surname, username, password, age, and email address  Example 17-1. 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

4 The validate.html Document (Part Two)  a set of six functions that do the actual form field validation  Example 17-2. Part two of the JavaScript validation form

5 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

6 Fuzzy Character Matching  The dot (.) is particularly useful  A simple way to do so is: / /

7 Grouping Through Parentheses  Character Classes  Indicating a Range  Negation  Some More Complicated Examples

8 Summary of Metacharacters  Table 17-1. Regular expression metacharacters  Table 17-2. Some example regular expressions  General Modifiers  Using Regular Expressions in JavaScript  Using Regular Expressions in PHP

9 Redisplaying a Form After PHP Validation  Example 17-3. The adduser.php program


Download ppt "JavaScript and PHP Validation and Error Handling CHAPTER 17."

Similar presentations


Ads by Google