1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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

Discussion in 'JavaScript and AJAX' started by hazrizal84, Jun 11, 2008.

  1. hazrizal84

    hazrizal84 New Member

    Joined:
    Jun 11, 2008
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    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.
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,283
    Likes Received:
    364
    Trophy Points:
    83
    Moved from Java to JavaScript forum
     

Share This Page