I am facing a challenge with a method that is supposed to allow all numeric values, including the '.' symbol. Below is the code for my method. While it successfully allows numeric values, it seems to have an issue with keyCode == 190
.
function IsNumeric(e) {
var keyCode = e.keyCode == 0 ? e.charCode : e.keyCode;
var ret = (keyCode >= 48 && keyCode <= 57 && keyCode == 190);
document.getElementById("error_numeric").style.display = ret ? "none" : "inline";
return ret;
}
<input class="form-control" name="teacher_cnic" value="" onkeypress="return IsNumeric(event);" type="text" placeholder="12345.1234567.1" required>
This method is called within a form using
onkeypress="return IsAlphaNumeric(event);"