Unit 14.2. Regular Expressions in Form Validation

The JavaScript validation script discussed in Unit 14.1 tests only for an empty value in the case of text fields. This is not a very stringent form validation. A space in the text field would be enough to pass this script’s validation test. Stricter validation is usually more desirable so that as much validation is done on the front-end as possible. Other things that could be checked are:

  1. Whether a field exceeds its maximum length.

  2. Whether only numbers were entered into the Phone Number field.

  3. Whether only text was entered in the First Name and Last Name fields.

Writing the code to test for the length is possible with the JavaScript introduced so far in this book. However, to check if only numbers ...

Get Oracle® Web Application Programming for PL/SQL® Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.