Results 1 to 2 of 2

Thread: Keypress event

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2000
    Location
    Kalix, Norrbotten, SWEDEN
    Posts
    343

    Keypress event

    I want to return keycode 0 when the user enters anything else than a number in a textbox.

    I have made a eventhandler, I check the keycode or the which if the navigator is a netscape.

    If the ascii code is anything else than a number I set the keycode = 0 in IE, and the which in netscape = 0. This works in IE, why not in Netscape???

    Help needed...

    /Smirre
    Visual Basic
    C, C++
    Java
    Access
    SQL Server

    MCP, MCSD

  2. #2
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606
    Hi Smirre

    I usually just do it on the OnBlur event of the text field !

    here's my function


    Code:
    		function isNum(txt){
    			if (isNaN(txt.value)){                
    				alert('Numbers only!');
    				txt.focus();
    				txt.select();
    				}
    		}

    usage:
    onBlur="isNum(this);"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width