Validating Digits and Dates with jQuery`s Validator Plug-in
In this fifth installment of a seven-part series on the jQuery JavaScript framework's Validator plug-in, I introduce the “digits” and “date” options. They're very useful for verifying that specified fields of a targeted form contain numeric values and valid dates.
Validating Digits and Dates with jQuery`s Validator Plug-in - Review: the range, email and url options (Page 2 of 4 )
Before we learn the new material, I'm going to review how to use the Validator plug-in to validate numeric ranges, email addresses and URLs. So, here’s the full source code corresponding to the examples developed in the preceding article. It demonstrates the use of the “range,” “email” and “url” options when validating a basic web form.
(example on using the ‘range’ option)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
As shown by the above code samples, validating numeric ranges, well-formatted email addresses and URLs is a straightforward process that can be tackled with minor hassles. In each of the three cases represented previously, the verification task has been accomplished by using a simple argument, which naturally has been passed to the pertinent “validate()” method. It’s that easy, really.
Well, having reviewed how to work with the “range,” “email” and “url” options provided by the Validator plug-in, it’s time to explore other validation arguments. As I explained in the introduction, the plug-in permits you to check if the field of a web form has been filled in with a string that contains only digits via another option called, not surprisingly, “digits.” Therefore, in the next section I’m going to illustrate how to use this useful option in a concrete case.
Now, to learn how to utilize the “digit” argument, please click on the link below and read the next few lines.