Click here to Skip to main content
15,886,067 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have developed one application in php. For the textbox I have given a string data type but it is accepting both text and numbers. what should I do? I want that textbox to accept only the text not the numbers.

Plz help me out........
Thanks....

What I have tried:

I have tried to use is_numeric($a) function but I want the textbox not to accept the number.
Posted
Updated 23-Jun-16 18:31pm
Comments
Sinisa Hajnal 23-Jun-16 6:25am    
Handle keydown event and prevent numbers from being typed in. Google it. Very common and very simple problem. And next time to it first, then come to ask if you don't find anything.
Sergey Alexandrovich Kryukov 23-Jun-16 10:08am    
Not clear: "numbers" is also text. Filtering of characters should be done in JavaScript, on the client side, not PHP. Your server side can sanitize the whole text after it is posted to the server side, if you need it.
—SA

Please see my comment to the question.

See, for example, this quick manual: Keyboard Text Input Filtering: Examples.

See also:
keypress,
Event.preventDefault(),
Event.defaultPrevented,
Event.cancelable,
Event.stopPropagation().

—SA
 
Share this answer
 
Thank You for the solution ........
But i have implemented the solution in which I am not allowing the keycode(ASCII) values to be entered in the textbox.
Hope it will be useful for others....
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900