javascript - Disable only .(DOT) special charecter in input field -
i don't want allow user enter. (dot) in input field.. rest of required validation done already.
function isnumberkey(evt) { var charcode = (evt.which) ? evt.which : event.keycode; if (charcode != 46 && charcode > 31 && (charcode < 48 || charcode > 57)) return false; return true; }
<input type="text" class="form-control" name="contactnumber" maxlength="10" value="" id="contactnumber" title="enter number here" onkeypress="return isnumberkey(event)" required>
$("#name").on("keypress", function(evt) { var keycode = evt.charcode || evt.keycode; if (keycode == 46) { return false; } });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <input type="text" id="name" />
working example here: jsfiddle
Comments
Post a Comment