Reputation: 147
When user type text a, b, c is ok.
If user type another text like 0, 9, z, x.... alert('can't type this word');
How to make it easily ?
Upvotes: 2
Views: 1189
Reputation: 30993
You can try use regular expression. example: http://www.9lessons.info/2010/01/jquery-validation-with-regular.html
or setup a powerful plugin like: http://bassistance.de/jquery-plugins/jquery-plugin-validation/
Upvotes: 1
Reputation: 8886
This is the link to allow Number and not alphabets (check the code here and make changes)....
Help your self finding out the key code for whichever alphabet you need to allow...
Here is the keycode
Upvotes: 1
Reputation: 100175
Do something like this:
$(document).ready(function() { $("#yourInputId").keyup(function() { if($(this).val() == "z") { alert("You cant type this"); } }); });
Upvotes: 1