jQuery validation plugin , add custom method

Posted by Eatdoku on Stack Overflow See other posts from Stack Overflow or by Eatdoku
Published on 2010-04-29T00:18:34Z Indexed on 2010/04/29 0:27 UTC
Read the original article Hit count: 301

Filed under:
|

Hi,

I am trying to add a method that validate a field to see if it contains a number value.

so this is what i did, however it is not doing the check for me. anyone has any idea?

thanks

$(document).ready(function() {


        $.validator.addMethod('positiveNumber',
            function(value) {
                return Number(value) > 0;
            }, 'Enter a positive number.');

    });

and

jQuery('form').validate();
jQuery('.validateFieldToCheck').rules('add', {
            positiveNumber:,
            messages: {
                required: 'Field must contain a number.'
            }
        });

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about jquery-plugins