So basically the expression tries to match with a phone number like this (541) 754-3010 or like this 541-754-3010 or with spaces Now let’s move on to the Postal code part.
Here I have added a new variable called postal Code to fetch the postal code from the form then created another variable to store the postal code regular expression which we will be discussing in a second.
Each field in the form can have zero one or more validations. More info & downloads where Do My Validation One() and Do My Validation Two() are custom functions for validation.
First, let’s start by building the webpage and the validation code then we will talk about the regular expressions used to validate the strings.
First go to your html file and paste the following code : Here, I have a simple form.
So, most of the web developers prefer Java Script form validation.
There are many more rules but let's leave it at these basic rules.