Skip to main content
Known Participant
October 23, 2008
Question

Integer formating

  • October 23, 2008
  • 2 replies
  • 911 views
Hi,
I am new to CF so I realize this is a basic question.

I have a form field where an integer will entered with or with comma separators
eg : 12,234 or 12345.

Q1 : What CF function can I use to edit that it is a valid integer format?

Q2 : What CFfunction can I use to remove the comma and convert to an integer variable to store in a table.

Thanks in advance.
    This topic has been closed for replies.

    2 replies

    Inspiring
    October 24, 2008

    This helps?

    <cfset test="12,34,567.89">

    <h1>Numeric</h1>
    <cfif IsNumeric(test)>
    <cfoutput>Output:[#test#]</cfoutput>
    <cfelse>
    NotNumeric<br>
    </cfif><br>
    <br>

    <h1>LS Numeric</h1>
    <cfset test=LsParseNumber(test)>
    <cfif IsNumeric(test)>
    <cfoutput>Output:[#test#]</cfoutput>
    <cfelse>
    NotNumeric<br>
    </cfif><br>
    <br>
    hefterrAuthor
    Known Participant
    October 24, 2008
    Hi forber1,
    Not really. The IsNumeric fails with any commas in the input (although documented as... "Supports numbers in U.S. number format.").

    The LsParseNumner() is good for removing the commas but I'm still trying to validate that they are in the correct position if used.

    Thnaks for trying.

    Inspiring
    October 24, 2008
    hefterrAuthor
    Known Participant
    October 24, 2008
    Hi fober1,
    I'm having a heck of time tring to validate an integer with comma separaters (that are valid) as IsNumeric() seems to have a bug and will accept any combination of commas to the left of the decimal. Same for LSIsnumeric().

    This has to be a very common edit (my first CF application)? HHeeelllllllllllppp!!

    hefterr
    Inspiring
    October 24, 2008
    quote:

    Originally posted by: hefterr
    Hi fober1,
    I'm having a heck of time tring to validate an integer with comma separaters
    hefterr

    what happened when you tried the answers to the other edition of this question?