In this post, you will learn how to check value is not equal to zero using Validate js

Considering you have form and its id is form_id and have field amount, 
Below Jquery code works : 

var validator = $("#form_id").validate({
    rules: { 
        amount: {
            required:true,              
            number: true,
            notEqual: '0'
        }
    }, 
    messages: { 
        amount: {
            required: "Please enter Amount",               
            number:"Please enter numbers only",
            notEqual:"Amount can not be zero"
        }
    },
    submitHandler: function() {  
        form.submit();
    }
});
jQuery.validator.addMethod("notEqual", function (value, element, param) { // Adding rules for Amount(Not equal to zero)
    return this.optional(element) || value != '0';
});
Written by
Check out this Author's contributed articles.
If you like Tutorialsmint and would like to contribute, you can also write an article using Write an Article. See your article appearing on the Tutorialsmint main page and help other programmers to enhance their knowledge.

Comments(0)

RECENT TUTORIALS
Wed Dec 26 • 08:00 AM GMT
Wed Dec 26 • 08:00 AM GMT
Wed Dec 26 • 08:00 AM GMT
Wed Dec 26 • 08:00 AM GMT
Wed Dec 26 • 08:00 AM GMT
Edit Post
Add Reply