Input field dot restrictions
Input field check dot in one time in js
by Ankit Patidar
HTML
<input class="myfeild" type="text">
JavaScript
$(".myfeild").on("keydown", function (evt) {
var charCode = (evt.which) ? evt.which : event.keyCode;
//console.log(charCode);
if (charCode > 31 && charCode != 110 && charCode != 190 && (charCode < 37 || charCode > 40 && charCode < 46 || charCode > 57 && charCode < 96 || charCode > 105)) { //31 to 37 for left right && 96 to 105 user for numpad
evt.preventDefault();
return false;
return true;
}
if (($(this).val().match(/\./g) || []).length > 1) {
console.log("enter!!!");
//var str = $(this).val().length;
$(this).val($(this).val().substring(0, $(this).val().length - 1));
}
});