ivanleoncz69
1 month ago

Jquery prevent different types of character

Posted 1 month ago by ivanleoncz69

I am trying to input only number and block rest of the character. here is my code

<input type="number" maxlength="9" id="poisa" placeholder="some chinese word :" name="budget" onkeypress="return (event.charCode !=8 && event.charCode ==0 || (event.charCode >= 48 && event.charCode <= 57))">

<script>
  $(document).ready(function(){
    $('#poisa').on("cut copy paste",function(e) {
      e.preventDefault();
    });
  }); 
</script>

it is working well when caps lock is not on. but when caps lock is on it is taking double byte character likesome chinese word. i want to prevent this kinds of characters. How to do it by jquery?

Please sign in or create an account to participate in this conversation.