user962408
user962408

Reputation: 147

jQuery ~ How to check text in input value

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

Answers (3)

Irvin Dominin
Irvin Dominin

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

Wasim Karani
Wasim Karani

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

Sudhir Bastakoti
Sudhir Bastakoti

Reputation: 100175

Do something like this:

$(document).ready(function() {
  $("#yourInputId").keyup(function() {
     if($(this).val() == "z") {
        alert("You cant type this");
     }
  });
});

Upvotes: 1

Related Questions