|
Hi all,
I have a form made with text boxes. I need to create two simple javascript functions which is not containing the text box name or id, but checks the text box when something is typed in the text box. No matter from which text box name or id it is called, this functions must work. Because I need to use these functions for multiple text boxes.
1- First function restricts the user typing the keys which are not 0-9
2- Second function restricts the user typing the keys which are not a-z/A-Z
For example:
When someone types 0-9 or any other characters to my first field which uses a-z/A-Z only function, gives an alert of "Please use only letters".
When someone types a-z/A-Z or any other characters to my second field which uses 0-9 only function, gives an alert of "Please use only numbers".
Please note that I am a beginner and try to explain as basic as possible. (calling the function from the code on key press etc. etc.)
Thanks very much.
|