<input name="phone" id="phone" placeholder="Mobile Number" class="form-control" type="number" required>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
$("#phone").keydown(function(event) {
k = event.which;
if ((k >= 96 && k <= 105) || k == 8) {
if ($(this).val().length == 10) {
if (k == 8) {
return true;
} else {
event.preventDefault();
return false;
}
}
} else {
event.preventDefault();
return false;
}
});
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
$("#phone").keydown(function(event) {
k = event.which;
if ((k >= 96 && k <= 105) || k == 8) {
if ($(this).val().length == 10) {
if (k == 8) {
return true;
} else {
event.preventDefault();
return false;
}
}
} else {
event.preventDefault();
return false;
}
});
</script>
No comments:
Post a Comment