Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Javascript Question Remove Leading zero's

Contributor ,
May 24, 2006 May 24, 2006
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
TOPICS
Getting started
1.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 24, 2006 May 24, 2006
Multiply by one removes the leading zeros. <CFSET foo = 1 * userData)> Be sure to do this after you verify that userData is numeric.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 24, 2006 May 24, 2006
LATEST
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.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources