-4

How to validate input box for only text input using jquery and php e.g name _ must accept only text input and no special character like "aaa@ or @@@ aaaa" and alpha numeric like "aaa123"

safarov
  • 7,793
  • 2
  • 36
  • 52

3 Answers3

0

You will want to use regular expressions I think. Take a look at this question which is pretty much the same as yours (except that it isnt about jquery) with PHP and all..

edit: Or as ComFreek points out, you can use the ctype_alnum function!

edit 2 ctype_alpha is actually what you are looking for; all alphabetic characters.

Checks if all of the characters in the provided string, text, are alphabetic. In the standard C locale letters are just [A-Za-z] and ctype_alpha() is equivalent to (ctype_upper($text) || ctype_lower($text)) if $text is just a single character, but other languages have letters that are considered neither upper nor lower case.

Community
  • 1
  • 1
Bono
  • 4,757
  • 6
  • 48
  • 77
0

Ideally you want both jquery and php validation, jquery for a better user experience and php for data integrity.

bendataclear
  • 3,802
  • 3
  • 32
  • 51
0

regarding to this, you must look into the ascii table... A-Z is representing 65-90

you just need to detect the value that return when onkeyup in html...

Whatever Kitchen
  • 700
  • 2
  • 14
  • 24