I am using jQuery validation. I am using minlength:8 and maxlength:10 for a mobile number.
Validation is working if I add 7 number
Note: I added 7 number with a dot(.) means 8 and it's accepted.
( If I add dot(.) at the end the I am getting the error)
Note: I added 9 number and it's accepted.
Is there any way that the user can enter eighter 8 number or 10 number?
Would you help me out with this?
$("#testForm").validate({
rules: {
mobileno: {
minlength: 8,
maxlength: 10,
number: true
}
},
submitHandler: function(form) {
$.ajax({
url: baseUrl + "/Test_control/submitForm",
type: "POST",
data: $('#testForm').serialize(),
success: function(data) {
window.location.href = baseUrl + "/all_thankyou";
},
}); // AJAX Get Jquery statment
}
});
<form name="form" id="testForm" action="#" method="post">
<input type="text" name="mobileno">
<input type="submit" name="send" value="Submit">
</form>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.0/jquery.validate.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.0/additional-methods.min.js"></script>