JQuery Validation Library (Document! X Sample)
jQuery Namespace / validator type
In This Topic
    validator type
    In This Topic
    var options; // Type:  jQuery.validator.options
    var instance; // Type:  jQuery.validator
    instance = $(".selector").validate(options);
    function validator;
    The following example illustrates how jQuery.validator might be used to validate a registration form.
    // Wait for the DOM to be ready
    $(function() {
      // Initialize form validation on the registration form.
      // It has the name attribute "registration"
        // Specify validation rules
        rules: {
          // The key name on the left side is the name attribute
          // of an input field. Validation rules are defined
          // on the right side
          firstname: "required",
          lastname: "required",
          email: {
            required: true,
            // Specify that email should be validated
            // by the built-in "email" rule
            email: true
          password: {
            required: true,
            minlength: 5
        // Specify validation error messages
        messages: {
          firstname: "Please enter your firstname",
          lastname: "Please enter your lastname",
          password: {
            required: "Please provide a password",
            minlength: "Your password must be at least 5 characters long"
          email: "Please enter a valid email address"
        // Make sure the form is submitted to the destination defined
        // in the "action" attribute of the form when valid
        submitHandler: function(form) {
    Inheritance Hierarchy


    Browser Compatibility
    See Also