Form .validate With Jquery - Use Both Errorplacement And Showerrors
I am trying to make validation with Jquery .validate plugin. I can't use errorPlacement and showErrors methods together. JsFiddle: Working errorPlacement - http://jsfiddle.net/5RrG
Solution 1:
Both works with
showErrors: function(errorMap, errorList){
this.defaultShowErrors();
},
Solution 2:
You could do this:
$(document).ready(function(){
$("#registerForm").validate({
errorPlacement: function(error, element) {
error.insertAfter(element);
},
showErrors: function(errorMap, errorList){
var $errorDiv = $("#errordiv").empty().show();
this.defaultShowErrors();
var errorsCombined = "";
for(var el in errorMap){
errorsCombined += "<b>"+ el + "</b>" + errorMap[el]+"<br/>";
}
$errorDiv.append(errorsCombined);
},
submitHandler: function(form) {
// Submit the form
form.submit();
},
invalidHandler: function(event, validator) {
}
});
});
Fiddle: http://jsfiddle.net/maverickosama92/5RrGa/1863/
Post a Comment for "Form .validate With Jquery - Use Both Errorplacement And Showerrors"