February 2014
Intermediate to advanced
410 pages
8h 15m
English
When collecting data from a user, there are many situations when you will want to only allow numbers in a form field. Examples of this could be telephone numbers, PIN codes, or ZIP codes, to name a few. This recipe will show you how to validate the telephone number field within the form we created in the previous recipe.
Ensure that you have completed the previous recipe and have the same files available. Open validation.js in your text editor or IDE of choice.
Add number validation to the form you created in the previous recipe by performing the following steps:
validation.js to be as follows, adding the valdiateNumber() function with an additional hasClass('number') check inside the for ...Read now
Unlock full access