blasterstudios
Technical User
I want to validate keystrokes and only allow lowercase letters, numbers, underscore, and dash. No spaces, no capital letters, and no special characters or symbols. I want it to check my form on the fly as well. So like on the onKeyPress event, it checks it. How do i go about doing this?
Here's what I tried, but it doesn't work:
Here's what I tried, but it doesn't work:
Code:
function letternumber(e)
{
var key;
var keychar;
if (window.event){
key = window.event.keyCode;
else if (e)
key = e.which;
}
if ((key==null) ||
((key>=97) && (key<=122)) ||
((key>=48) && (key<=57)) ||
(key==95) || (key==45) || (key==97))
return true;
else
return false;
}