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

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -