Jump to content

Number fields only, isNaN function


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
https://forums.phpfreaks.com/topic/277997-number-fields-only-isnan-function/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.