+ 1

What conditions should be applied if i want a text field to take only alphabet as input?

6th Nov 2016, 11:59 AM
Atul Ranjan
Atul Ranjan - avatar
3 Respuestas
+ 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 }
6th Nov 2016, 12:21 PM
Schindlabua
Schindlabua - avatar
0
if i apply only html then it wont take white space
8th Nov 2016, 4:32 PM
Atul Ranjan
Atul Ranjan - avatar
0
you can use the HTML 5 attribute <form> <input type='text' pattern='[A-Za-z\\s]*'/> </form>
1st Jan 2018, 7:55 PM
Adarsh Singh
Adarsh Singh - avatar