javascript - onblur()..... really need your help..

hazrizal84's Avatar, Join Date: Jun 2008
Newbie Member
hi..i really need help from those who can solve my prob..here there are:

<html>
<head>
<script language=javascript>
function isNumberKey(evt)
{
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 47 || charCode > 57))
return false;

return true;
}
</script>
</head>
<body>
<p>Please enter your answer or type ( / ) if you don't know the answer.<br>
Your answer may not contain both numbers and ( / ) sign.<br><br>
34 + 54 = <input type=text size="6" onkeypress="return isNumberKey(event)" onblur=""></p>
<p>123 + 76 = <input type=text size="6" name="T1" onkeypress="return isNumberKey(event)" onblur=""></p>
<input type=submit value="Check Answer!">
</body>
</html>

User will be able to key in their answer in numerical form or just type slash ( / ) for unknown answer..the prob is, how can i build up the function in onblur() statement so that, when tab button been pressed to move to the other textbox, it will determine whether user key in number, slash or the combination of number and slash. message box will be popped up if user key in both number and slash in the space provided.
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Moved from Java to JavaScript forum