validation - jQuery Validate - display one warning for the same types of errors -
i have simple form has several input elements required:
$("input").each(function(index, elem) { var rules = { required:true } $(elem).rules("add", rules); });
and want place error messages in div, this:
<div id="errorcontainer" class="inputgreska"> there errors. please correct following: <ul id="errorlabelcontainer"></ul> </div>
so, did following:
$("#forma").validate({ errorclass: "red", errorcontainer: "#errorcontainer", errorlabelcontainer: "#errorlabelcontainer", wrapper: "li", errorelement: "div" });
the problem following:
if user forgets fill more 1 input - within error container there same warnings repeated. so, if user forgets fill 3 fields, there be:
- this field required.
- this field required.
- this field required.
is possible show 1 error message, this:
fields marked asterisks (*) required
no matter how many elements user has forgotten fill.
thank you.
if understand you're question right wanting display 1 error message form validation though has multiple errors, try using showerrors() callback defined in jquery validate.
showerrors: function (errormap, errorlist) { $("#errorcontainer").html("please enter required fields asterisk*."); }
have pulled quick fiddle show working example http://jsfiddle.net/mvz0c2am/ , hope helps.
Comments
Post a Comment