Custom jquery validate messages for all errors -
how can specify custom error message each error type, required , date. want different message depending on error type.
i have field looks this
<input type="text" id="dateofbirth" name="dateofbirth" class="required date" />
my error messages this
this field required
or please enter valid date
how can make following
date of birth required
, please enter valid date date of birth
i'm using
var validator = $("form:first").validate({ errorclass: 'input_state_error', rules: { dateofbirth: "required date" }, messages: { dateofbirth: "please enter date of birth" }, // errorplacement has take table layout account errorplacement: function(error, element) { error.appendto($('#ctl00_lblmessage')); }, // specifying submithandler prevents default submit, demo submithandler: function() { alert("submitted!"); }, // set class error-labels indicate valid fields success: function(label) { // set text ie label.html(" ").addclass("checked"); } });
following jquery date()
documentation validation plugin, guess suggest this:
var validator = $("form:first").validate({ ... messages: { dateofbirth: { required: "date of birth required", date: "please enter valid date date of birth" } } ... });
Comments
Post a Comment