+ 1
What conditions should be applied if i want a text field to take only alphabet as input?
3 Answers
+ 3
In pure HTML:
<form>
<input pattern="[a-zA-Z]*" required />
</form>
in javascript:
if(myInput.value.match(/[a-zA-Z]*/)){
// everything ok
}else{
// notify the user that he messed up
}
0
if i apply only html then it wont take white space
0
you can use the HTML 5 attribute
<form>
<input type='text' pattern='[A-Za-z\\s]*'/>
</form>