0

I have the below code to recognize the special ASCII codes before submit the form. How can I set condition to change that ASCII codes with character space? For example, I don't want the user enter ; and I want to change this character with space.

Here is my code :

function isNumberKey(evt) {
  var charCode = (evt.which) ? evt.which : event.keyCode
  if (charCode > 31 && (charCode < 48))
    return true;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<form method="post" action="#">
  <input name="mastername" type="text" onkeypress="return isNumberKey(event)">
  <input type="submit" value="submit">
</form>
Hadis
  • 43
  • 4

0 Answers0