Reputation: 1261
I am busy with some form validation and it is working but the messages keep on comming when you make a mistake.
So when you fill out in the emailfield with only a name the error comes but when you click again in that field the same message come up again.
How can i fix this that the message will be showing only one time? And when it's good that the message disappear?
Example: http://jsfiddle.net/q7Z82/
Upvotes: 1
Views: 235
Reputation: 21376
you can use errorPlacement
option http://docs.jquery.com/Plugins/Validation/validate#options. like this,
$("form.valid").validate({
errorLabelContainer: "div.messages",
// errorElement: "div class='system error'",
meta: "validate",
errorPlacement: function(error, element) {
error.insertAfter(element);
},
});
here is the demo http://jsfiddle.net/q7Z82/2/
Upvotes: 1
Reputation: 1226
You could try something like the below:
$("form.valid").validate({
errorLabelContainer: "div.messages",
errorElement: "div class='system error'",
meta: "validate",
onkeyup: false,
onclick: false
});
In terms of the message disappearing you could use any timeout you desired (say 1 second) and then have a call to the jQuery empty method.
setTimeout(function () { $("div.messages").empty() }, 1000)
Upvotes: 0