Jump to content

Number fields only, isNaN function


frank_solo
Go to solution Solved by frank_solo,

Recommended Posts

I have a few fields in which I just want the user to input numbers. I thought I wrote the srcipt correctly but it seems not be working. Can anyone please tell me what I am doing wrong. I very new to this. Thanks

<script Language="JavaScript">
<!-- 
function Number_Validator()
{
  var valid = true;
  if(isNaN(refine_table.min_sq.value)) 
   { 
     alert("Only numbers are allowed in the Square Footage fields."); 
     refine_table.min_sq.focus(); 
     return (false); 
   }
  if (!valid) alert(msg);
  if(isNaN(refine_table.max_sq.value)) 
   { 
     alert("Only numbers are allowed in the Square Footage fields."); 
     refine_table.max_sq.focus(); 
     return (false); 
   }
  if (!valid) alert(msg);
  if(isNaN(refine_table.min_price.value)) 
   { 
     alert("Only numbers are allowed in the Amount fields."); 
     refine_table.min_price.focus(); 
     return (false); 
   }
  if (!valid) alert(msg);
  if(isNaN(refine_table.max_price.value)) 
   { 
     alert("Only numbers are allowed in the Amount fields."); 
     refine_table.max_price.focus(); 
     return (false); 
   }
  if (!valid) alert(msg);
  return valid; 
}
-->
</script>
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.