I am using jQuery validation plugin to validate the form data. It works fine on form submit. But `onkeyup` and `onblur` it is not working.
jQuery code:
---------------
var validator = $("#myForm").validate( {
rules:{
attribute: "required",
attributeValue: "required email"
},
messages:{
attribute: "Required",
attributeValue: {
required: "Enter email",
email: "Enter valid email"
}
}
});
Am I doing anything wrong here?
Assuming your .validate() is wrapped inside a DOM ready event hander, there is nothing wrong with your code, and the plugin will validate onfocusout and onkeyup by default. Perhaps you should consider using a newer version of jQuery than 1.5.2, since you're using v1.11 of the plugin. See: jsfiddle.net/rfKaE
以上就是jQuery validation plugin not validating the fields onblur and onkeyup的详细内容,更多请关注web前端其它相关文章!