Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript_howto thread: Netscape focus()


Message #1 by "Phil Kimble" <phil@p...> on Mon, 13 May 2002 22:19:18
The following code works in IE, but Netscape goes into a loop.  I just 
want to test if an entry is numeric.  If not, put the focus back on the 
field for correction (and select it for user convenience).  Netscape gives 
my alert, and when I press OK to clear the alert, it flashes back to the 
field and then gives the alert again.

Thanks for your help!
Phil

function checkNumeric(inputObject)
{
   if (inputObject.value == "")
   {
      return true;
   }
   if (isNaN(inputObject.value))
   {
      inputObject.focus();
      inputObject.select();
      alert ("This entry must be a number!!");
      return false;
   }
   else
   {
      insertCommas (inputObject);
      adjustRight(inputObject,22);
      return true;
   }
}


  Return to Index