Validating Numeric values

Results 1 to 2 of 2

Thread: Validating Numeric values

  1. #1
    Join Date
    Dec 1969

    Default Validating Numeric values

    I have a form that needs to be validated. I am using javascript to validate what the user inputs. I use the isNaN function which checks to see the the value the user inputs is a number. The problem with this function is that if the user enters 1,000 instead of 1000 it thinks its not a number because of the comma. How can I get around this issue?<BR>

  2. #2
    Heaven's Martini Guest

    Default The martini rolls his own.....

    this is what I do.<BR><BR>Call this onBlur.<BR>first is the formfield reference,<BR>the second would be the character set<BR>&#039;0123456789,.&#039; in your case,<BR>the error message you want to say.<BR><BR>note* sql server does not like commas in int fields.<BR><BR>function checkValue(fmfld,charset,errormessage) <BR>{<BR><BR> var noerror = true;<BR> var Chars = charset;<BR> <BR> if (fmfld.value) <BR> {<BR> for (var i = 0; i &#060; fmfld.value.length; i++) <BR> {<BR> if (Chars.indexOf(fmfld.value.charAt(i)) == -1)<BR> {<BR> noerror = false;<BR> }<BR> }<BR> <BR> if (!noerror)<BR> {<BR> if (errormessage.length &#062; 0)<BR> alert(errormessage);<BR><BR> fmfld.focus();<BR> return noerror<BR> }<BR> } // *** if nothing in field skip validation ***<BR> return noerror;<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