|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Simple verification
I wanted to make simple textarea verification in Javascript.
I wanted to prevent user from typing some characters, allowing only a..zA..Z0..9 ' I thought that when I return false during onKeyPress event associated with the textarea, it will prevent that character from displaying. But it doesn't work. What's wrong? Code: function Onlyalfanum(key) { c = false; if (key>=97 && key<=122) c = true; if (key>=65 && key<=90) c = true; if (key>=48 && key<=57) c = true; if (key==32 || key==39) c = true; return c; } ... <textarea onKeyPress="return Onlyalfanum(event.keyCode)"></textarea> |
|
#2
|
||||
|
||||
|
RE: Simple verification
You never use the variable the function returns. I suggest that in the form handler php script you do a regexp check.
|
|
#3
|
|||
|
|||
|
RE: Simple verification
Hmm, I have read somewhere (Javascript Reference Book I think), it should work this way. But the implementation have been changed, apparently.
I will look for up-to-date version. To tkarkkainen: I want to do it on client-side so as not to waste server resources. |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Client Side Things > Simple verification |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|