I'm trying to validate if input emailId and phone number exists or not using jQuery Validation plugin(remote method). But i Don't know where i am going wrong. I tried using add method plugin but didn't work.can anyone help me where am i going wrong??
Here is the code.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.14.0/jquery.validate.min.js"></script>
<script src="http://cdn.jsdelivr.net/jquery.validation/1.14.0/additional-methods.js"></script>
$('#myForm').validate({ // initialize the plugin
rules: {
emailId: {
required: true,
email: true,
remote: {
url:'verifyEmailOrPhone-'+$('#emailId').val()+'-'+$('#contactNumber').val(),
type:'GET',
}
},
contactNumber:{
required: true,
minlength: 9,
maxlength: 10,
number: true,
remote: {
url:'verifyEmailOrPhone-'+$('#emailId').val()+'-'+$('#contactNumber').val(),
type:'GET',
}
},
},
messages:{
emailId:{
remote: "emailId already taken"
},
contactNumber:{
remote: "phone number exists"
}
},
submitHandler: function (form) {
// for demo
alert('valid form submitted'); // for demo
return false; // for demo
}
});
html
<div class="margin-top-10 contact-check has-feedback form-group" >
<input class="form-control input-lg" name="contactNumber" id="contactNumber" placeholder="Phone Number" size="25" type="text" value="">
</div>
<div class="margin-top-10 email-check form-group has-feedback" >
<input class="form-control input-lg" name="emailId" id="emailId" placeholder="Email" size="25" value="" type="text">
</div>
in console i'm getting http://localhost:8080/SpringMvcExample/verifyEmailOrPhone--?emailId=bhagya%40gmail.com
remote method is returning "emailId=bhagya%40gmail.com" in url where i need to return only input data.