I am using jquery.validate to check my form for errors and I am trying to get the id of the element that has raised an error.
Here is my basic working code, hopefully it should be clear from this what I am after:
function customError(){
alert("this is where I want the element ID");
}
function submitForm($form){
$form.validate({
required: customError(),
errorPlacement: function(error, element) {},
submitHandler: function(){
alert("submited");
}
});
}
...
errorPlacement: function (error, element) {
customError(element.attr('id'));
},
...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.