If it is for onkeydown event, then it should be:
return (event.keyCode>=65 && event.keyCode<=90 || event.keyCode==32);
to capture the actual keyboard key.
Check this out:
Keyboard events | JavaScript Tutorial[
^]
+++++[round 2]+++++
Quote:
it functions well but i cannot erase?cannot use backspace :O
Then add one more condition to check for backspace key,
return (event.keyCode>=65 && event.keyCode<=90 || event.keyCode==32 || event.keyCode==8);
Refer to this for other keycodes in JavaScript
KeyboardEvent Value (keyCodes, metaKey, etc) | CSS-Tricks[
^]
+++++[round 3]+++++
Quote:
hey man another question i tested now to validate and allow only numbers and colon and backspace i try this codes onkeydown = "return (!(event.keyCode>=65 && event.keyCode!=32 || event.keyCode==186 || event.keyCode==8;" but it didnt work well for me ?
I have given you enough code and reference, It is up to you to straighten up your logic. If you want to accept numbers, what is the range of keycodes for numbers? If you do not want to accept space, why bother including it then checking that it is not? Watch the syntax too.