Coldfusion server side validation decimal-number

Posted on 2009-02-18
Last Modified: 2013-12-20
Hello experts.
I need help to validate a textfield and allow number with decimals without using jacascript.The code below is validating if it is a anumber with postive values but it does not allow decimal values(f.e 12,25).
Any help to fix this?
<cfif Form.Submitted EQ 1>

  <cfif Form.Prozent NEQ "">

  <cfif NOT IsNumeric(Form.Prozent) OR   Form.Prozent LTE 0>

    <cfset errors = errors & "Bitte eine postive Nummer  ins Prozent-Feld eingeben! (z.B 12,50)<br>">

    <cfset ProzentError = 1>





<input name="prozent" type="text" <cfif ProzentError EQ 1> class="textfieldprozentwarn"<cfelse>class="textfieldprozent" </cfif> id="prozent" maxlength="5"  value="<cfoutput>#Form.Prozent#</cfoutput>"/>

<input  name="INSERT" type="submit">

                       <input  name="submitted" type="hidden" value="1" />


Open in new window

Question by:Panos
    LVL 4

    Accepted Solution

    Dear panosms,

    check out the ColdFusion Function LSParseNumber ( ) as you are trying to input german numeric values.

    This should work.
    Hope that helps.
    LVL 2

    Author Comment

    On this site:
    i found a tag named ListValueCount.I have not make it work yet.
    I will try it tomorrow again.Can you take a look too?
    LVL 2

    Author Comment

    Hi eclipse2k.
    I will keep the 34.34 format.
    So i don't need the german numeric values.
    Thank you for your help.
    LVL 2

    Author Closing Comment

    thank you again
    LVL 4

    Expert Comment

    Hey panosms,

    The Function (not a tag) named "ListValueCount" is a basic ColdFusion tag, you can find more information here:

    which ColdFusion version are you using? I don't see any problems using that function.

    Please note that the tutorial at the page you mentioned above is very old (2003) and the technique used is old too, as it was designed for ColdFusion versions prior to 6.1. When you are using a modern ColdFusion version like MX 7 oder CF 8, you should check out this much more advanced techniques:

    LVL 2

    Author Comment

    Hi eclipse2k:
    I had two problems.The first to allow only postive number values without any , or .
    and the other to allow positive numbers that allow (,) and not (.)
    so for the first i find out that the code that is checking what i want is:
    <cfif NOT IsNumeric(Form.Test) OR NOT IsValid('integer',Form.Test) OR   Form.Test LTE 0>
        <cfset errors = errors & "....blabla....">
        <cfset TestError = 1>
    For the second i decided to use the format with a (.) as i saw that the IsNumeric format ia checking this.
    I did not find out how to check how many decimals to allow.
    Well if you want to make a comment about all these i would be very happy.!!

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    Introduction In this tutorial, I'll explain how to create an animated progress meter in a wireframe prototype developed using Axure RP 7.0 - a leading prototyping tool for designing web sites and software. (For more information about Axure and gett…
    If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
    The purpose of this video is to demonstrate how to create a Printer Friendly PDF on a WordPress Page. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome Screenshot” Google Chrome Extension, and Log…
    The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now