I have a hidden Input form that has a value of 78, I am using javascript to
validate that the amount the User entered in a new Input form is greater than
the amount in the hidden form. But this is failing when a user enters stuff
like 0775 or 000745. Is there a way I could remove the leading o's zeros and
then do the validation. <cfinput validate integer> allows entering of leading
zeros, I want to remove the leading zeros. Is it possible?
Thanks
Dan Bracuk - 24 May 2006 18:12 GMT
<blockquote>quote:<br><hr><i>Originally posted by: <b><b>jdeline</b></b></i>
Multiply by one removes the leading zeros. <CFSET foo = 1 * userData)> Be
sure to do this <i>after</i> you verify that userData is
numeric.<hr></blockquote>
Regarding ensuring the value is numeric, be careful of using the js parseint,
parsefloat or whatever those functions are called. They don't always return
NaN (not a number) for non-numeric strings.
amadeusmax - 27 May 2006 22:20 GMT
I am going out on limb here and assuming that your looking at a string. The
solution would be convert to a number
parseFloat('00785')
which would make 785
>I have a hidden Input form that has a value of 78, I am using javascript to