Jump to content


Photo

Number fields only, isNaN function

javascript

Best Answer frank_solo, 14 May 2013 - 03:02 PM

Nevermind the fields were named differenttly. DOH!

Go to the full post


  • Please log in to reply
3 replies to this topic

#1 frank_solo

frank_solo

    Advanced Member

  • Members
  • PipPipPip
  • 109 posts

Posted 14 May 2013 - 02:33 PM

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>


#2 Psycho

Psycho

    Advanced Member

  • Gurus
  • 10,809 posts
  • LocationCanada

Posted 14 May 2013 - 02:49 PM

It is not working how? Are you getting errors or what?


The quality of the responses received is directly proportional to the quality of the question asked.

I do not always test the code I provide, so there may be some syntax errors. In 99% of all cases I found the solution to your problem here: http://www.php.net

#3 frank_solo

frank_solo

    Advanced Member

  • Members
  • PipPipPip
  • 109 posts

Posted 14 May 2013 - 02:57 PM

No errors just dosen't do what it is suppose to do.



#4 frank_solo

frank_solo

    Advanced Member

  • Members
  • PipPipPip
  • 109 posts

Posted 14 May 2013 - 03:02 PM   Best Answer

Nevermind the fields were named differenttly. DOH!






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com