0
Javascript Question Remove Leading zero's
Contributor
,
/t5/coldfusion-discussions/javascript-question-remove-leading-zero-s/td-p/860637
May 24, 2006
May 24, 2006
Copy link to clipboard
Copied
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
Thanks
TOPICS
Getting started
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

/t5/coldfusion-discussions/javascript-question-remove-leading-zero-s/m-p/860638#M79341
May 24, 2006
May 24, 2006
Copy link to clipboard
Copied
Multiply by one removes the leading zeros. <CFSET foo = 1
* userData)> Be sure to do this
after you verify that userData is numeric.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
LATEST
/t5/coldfusion-discussions/javascript-question-remove-leading-zero-s/m-p/860639#M79342
May 24, 2006
May 24, 2006
Copy link to clipboard
Copied
quote:
Originally posted by: jdeline
Multiply by one removes the leading zeros. <CFSET foo = 1 * userData)> Be sure to do this after you verify that userData is numeric.
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.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

