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.
The drop down select list boxes usually will have one item saying ‘Select One’ (and that item will be selected by default).
The user should select an option other than this ‘Select One’ item.
For ‘selections’ like drop down and radio group, use an appropriate validation like ‘dontselect’ or ‘selone_radio’.
This validation descriptor is valid only for drop down lists.
For example, you can have an input field that should not be empty, should be less than 25 chars and should be alpha-numeric. In some dynamically programmed pages, it may be required to change the validations in the form at run time.
In other words, in order to validate a field, you just associate a set of validation descriptors for each input field in the form. For such cases, a function is included which clears all validations in the validator object. Note that this validation if for fields like Textbox and multi-line text box.
Now let’s jump into the fun part which is discussing the regular expression First we have the starting and ending slashes “/” , the expression then starts with a “^” sign to match with the beginning of the string.
Notice the [-\s\.] this part matches a hyphen(-) space or a dot (.).[0-9] means 3 digits.
I am using simple HTML 4 elements to create user id input,first name,last name etc.
Using client side Java Script is an efficient way to validate the user input in web forms.