Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript_howto thread: Focus() in Netscape


Message #1 by "Phil Kimble" <phil@p...> on Sat, 25 May 2002 16:39:49
Greg,

This process starts with the onblur on the INPUT. onblur calls the 
receipts function which calls the sumReceipts function which calls the 
checkNumeric function. The code follows:

<TD> 
<INPUT name="Rcpt1" type="TEXT" maxlength="22"
       onblur="receipts(Rcpt1);"              
       onfocus="removeSpaces(Rcpt1,22);" VALUE="100"> 
</TD>   



function receipts(entry)
//
// Recalculate totals and subtotals after leaving a Receipts field
//
{
   if (sumReceipts(entry))
   {
      sec1NetTotal();
      sec1CheckTotal();
      sec1Difference();
   }
}




function sumReceipts(entry)  
{var subtotal = 0;  
 var valued = false;  
  if (checkNumeric(entry) == false)
  { return false;}
  if (document.SF224.Rcpt1.value != "")
    {subtotal = subtotal + ........
    
    
    
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;
   }
}

Thanks, again, for your help!

Phil


> Please post the code where this script is called, it is possible that NN 
is 
completeing the function once and then due to the activity of the 
function, 
the handler is being refired.

At 16:39 25/05/02 +0000, you wrote:
>The following code works in IE, but Netscape goes into a loop.  I just
>want to test if an entry is numeric.  If it is not numeric, I want to 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;
>    }
>}
>
>---
>
>Improve your web design skills with these new books from Glasshaus.
>
>Usable Web Menus
>http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
>r-20
>Constructing Accessible Web Sites
>http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
>r-20
>Practical JavaScript for the Usable Web
>http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
>r-20
>---
>Change your mail options at http://p2p.wrox.com/manager.asp or
>to unsubscribe send a blank email to 
>



  Return to Index