Eagerly validating User Input with Jquery

Below are two bullet points on the Jquery site for validation. They describe the behavior for the JQuery validation plugin, around Lazy and Eagerly validation for user input on a web page.

  • Before a field is marked as invalid, the validation is lazy: Before submitting the form for the first time, the user can tab through fields without getting annoying messages - he won't get bugged before he had the chance to actually enter a correct value
  • Once a field was marked invalid, it is eagerly validated: As soon as the user entered the necessary value, the error message is remove

Based on how the HTML is rendered, this behavior may not be observed. For instance, after calling validate() for a form, eargerly validation(validation on events like Mouseup/down and keyPressUp/down.) does not occur after corrections are made to validated input. To make sure that you get eagerly validation when using straight HTML markup for textboxes, make sure to add the input TYPE and NAME as illustrated below for the html elements. For example, the markup below illustrates the class, 'required number' so the textbox will first be validated to make sure a value is supplied and then it will check if the value is numeric after validating the form submission and then after changes as new data is entered.

<input name="id12" class='required number' type="text" />

Currently rated 1.5 by 11 people

  • Currently 1.454545/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by: BayerWhite
Posted on: 5/25/2012 at 2:31 AM
Tags: ,
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed