1

I want my input for Name is cannot typing number mean it only allow letter Now I use like this:

var key = e.keyCode;
 if (!((key == 8) || (key == 32) || 
    (key == 46) || (key >= 35 && key <= 40) || 
    (key >= 65 && key <= 90))) 
 {
  e.preventDefault();
 }

but It work on English letter only. Thank you for every help.

1

2 Answers 2

4

Just use the built in pattern attribute in HTML.

<input type="text" pattern="[A-Za-z]" title="no numbers">
Sign up to request clarification or add additional context in comments.

2 Comments

I know pattern="[A-Za-z]" can add other langue to it
The pattern is just RegEx, you can modify it any way you want.
0

Try this fiddle, it trigger's and rectifies on every input or change of the value to the control

$("#textbox").on("input",function(){ 
this.value=this.value.replace(/[^a-zA-Z]/gi, '')
})

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.