i tried pattern pattern="[A-Za-z]"
attribute of input type but it allows first and show error at last on form submit
any example of js,jq will be much helpful and appreciated
Thanks..
Asked
Active
Viewed 47 times
0

Moiz tandawala
- 15
- 3
-
Hello. Welcome to StackOverflow. Your question will have a better chance of being answered if you provide a [Minimum Complete Verifiable Example](https://stackoverflow.com/help/mcve) which demonstrates what the problem is and what you have tried to fix it. Consider reading the [How to Ask](https://stackoverflow.com/help/how-to-ask) guide and updating your question. Cheers :) – Chirag Ravindra May 11 '18 at 10:08
-
Yes, that's the expected behavior of HTML form validation. If you need a real-time validation, please do some search at SO, there are plenty of examples of real-time validations. – Teemu May 11 '18 at 10:15
1 Answers
0
The Expression you provided must be modified to: ^[A-Za-z -]+$
You can use either from below to match you criteria :
- 0 or more of the preceding expression
- 1 or more of the preceding expression
You can also onchange or onblur add method As ValidateText ex :
function lettersOnly()
{
var charCode = event.keyCode;
if ((charCode > 64 && charCode < 91) || (charCode > 96 && charCode < 123) || charCode == 8)
return true;
else
return false;
}
link : Javascript Function to enter only alphabets on keypress

Hany Habib
- 1,377
- 1
- 10
- 19