Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
$(document).ready(()=>{
$.validator.addMethod('nameLen',(value, element)=>{
return /([^a]{2}$)/g.test(value);
},"Your Email is not in proper format.... please correct the same......");
$("#form1").validate({
rules:{
inpt:{
required: true,
nameLen: true
},
inpt2:{
required: true
}
},
messages:{
inpt:{
required: "This field is mandatory"
},
inpt2:{
required: "This field is mandatory"
}
},
errorElement: "span",
errorPlacement: (error, element)=>{
if(element.attr("name") =="inpt"){
$(".err").html(error);
}
if(element.attr("name") =="inpt2"){
$(".err2").html(error);
}
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment