0

I am using Jquery Validate plugin to check the user input

however, i found that the option is not sufficient and i decided to use custom rules

Are there any website provide those rules?

What i would like to check is the format of date and integer only

Thank you

Leo Chan
  • 4,217
  • 8
  • 31
  • 47
  • try http://stackoverflow.com/questions/511439/custom-date-format-with-jquery-validation-plugin and http://stackoverflow.com/questions/995183/how-to-allow-only-numeric-0-9-in-html-inputbox-using-jquery – Larry Battle Apr 02 '12 at 03:13

2 Answers2

0

you can customized jQuery validate plugin like this.

jQuery("form#my-form").validate({
            rules: {
                //input field name "inputName"
                //implement your rules here
                inputName: {
                    minlength: 3
                }
            },
            messages: {
                inputName: {
                    required : 'Your customized message'
                }
            }
        });
jeewiya
  • 571
  • 11
  • 24
0

you can add custom rules by extending the jquery validator

   jQuery.validator.addMethod("customdate", function(value, element) { 
   return this.optional(element) || {your rules}
     }, "eg YYYY-MM-DD");

see in here

http://docs.jquery.com/Plugins/Validation/Validator/addMethod#namemethodmessage

For number only, you don't need to write your own rules.It already include the feature,try digits and number

  1  $("#form").validate({
        rules:{
            inputtype:{required:true,digits:true}

        },
        messages:{
            inputtype:{required:"Please provide Number",digits,"Number Only!"}

        }
    });

    2.  $("#form").validate({
        rules:{
            inputtype:{required:true,number:true}

        },
        messages:{
            inputtype:{required:"Please provide Number",number,"Number Only!"}

        }
    });
Winn Minn Soe
  • 341
  • 1
  • 2
  • 4