textbox validation w/ javascript

tonkacoach
04-04-2002, 07:41 AM
Can someone tell me how to use the keypress event for a text box that will force users to, say, enter numbers only. It's easy
to do in VB, but I'm sure how to do it with javascript. I know the function should look something like this ...

function txtBox_onkepress() {
if (??? < 97) or (??? > 122) then;
keycode = 0;
end if;
}

I may be missing some stuff but you get the idea. I've tried event and keycode where the ???'s are. Any help would be great!!!!

Thanks!
John

orufet
04-04-2002, 07:46 AM
Are you using JavaScript or VBScript???

tonkacoach
04-04-2002, 07:54 AM
I am looking to solve this dilemma with javascript. It will then work in both IE & NetScape. But VBScript wold be ok. I think I could rework it into JavaScript.

Thanks

Thinker
04-04-2002, 08:16 AM
In the input tag you will set a function for the onKeyPress event

<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">
<!--
function CheckKey() {
// code here
}
//-->
</SCRIPT>
<INPUT TYPE="text" NAME="mytextbox" onKeyPress="CheckKey()">

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum