Checking for numeric

Results 1 to 2 of 2

Thread: Checking for numeric

  1. #1
    Join Date
    Dec 1969

    Default Checking for numeric

    this is client side...<BR><BR>I have several input boxes where I need to make sure that the user only entered numeric character or "$" or "."<BR><BR>Good input:<BR>5<BR>$5<BR>$5.44<BR><BR>Bad inputs<BR>a<BR>$t.ii<BR><BR>I think that you get the idea, can some one make some javascript suggestions

  2. #2
    Steve Cimino Guest

    Default RE: Checking for numeric

    //get rid of commas (1,000.00) <BR>var yourvar = document.form.textboxname.value.replace(&#039;,&#0 39;,&#039;&#039;);<BR><BR> if (yourvar.charAt(0) == "$")<BR> {<BR> yourvar = parseFloat(yourvar.substr(1));<BR> }<BR> else<BR> {<BR> yourvar = parseFloat(yourvar);<BR> }<BR> <BR> if (isNaN(yourvar))<BR> {<BR> alert("Please enter a number in ###.## format.");<BR> return false;<BR> }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts