Validating numbers using jQuery
In the last recipe, we validated empty fields. In this recipe, we will extend that behavior and will check for numbers along with empty fields.
Getting ready
Create a new folder Recipe4
inside the Chapter5
directory.
How to do it...
Create a new file and save it as
index.html
in theRecipe4
folder. We will take the same code form as used in the previous recipe and will add another section to it. So, copy the code from the previous recipe to theindex.html
file. Now, we will add another section to it through which a user will be able to enter some numbers. Create another section named Other Details after the Personal section. It is important to note that these fields have another CSS class namednumber
along withrequired
assigned to them. This way we will be able to validate for empty fields as well as for numbers.<fieldset> <legend><strong>Other Details</strong></legend> <table> <tbody> <tr> ...