Validate if form field entered by user is valid number(not a negative value)

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default Validate if form field entered by user is valid number(not a negative value)

    Thank you so much for reading my question.

    Hi,

    I have a actionpage that allows update of information/price to my database.
    My form page consists of a price field(display in dollarformat) and I wanted
    to validate if the user has keyed in a negative price value.

    I have tried hidden type with name=price_range, value=MIN="0", but does not
    work. (Pls note: I have also declared hidden type _required, _float prior to
    the _range)

    But the funny thing is that another form field (of numeric value) has the same
    hidden type declaration (_required, _float, followed by_range) as the "price",
    and it works perfectly.

    My question is:
    Is the _range only applicable for numeric values? If it really does, then how
    should i go about validating my price (in currency)?
    Pls help me if you know.

    Millon thanks in advance.
    Regards,
    A novice in Coldfusion

    design in progress Guest

  2. Similar Questions and Discussions

    1. How do I validate the values entered for custom control properties?
      I have a custom control with properties named MinValue, MaxValue, and Value (all of which I have assigned a DefaultValue design-time attribute). The...
    2. SOS! To validate if form field entered by user is validnumber (not a negative value)
      Pls see my question as below... gclausen, This is actually a school assignment, which doesn't allow the use of Javascript. Anyone can help,...
    3. Counting the number of times a user hits an html form
      I have a very long html form with many loops in it. I'm trying to keep track of how many times a user hits a specific web page while they are...
    4. Validate 1st field on form
      Hi I have a form that users fill in, thefirst field is a username, which must be unique. Currently only when I attempt the Insert into the DB...
    5. Automatically update a field when another field is entered.
      I am trying to create a field in a form that will be automatically populated when another field is entered. I have facility names with related ID...
  3. #2

    Default Re: SOS! To validate if form field entered by user isvalid number (not a negative value)

    Use the cfinput "onValidate" attribute to call a client side javascript
    function. Like this:
    <script language="JavaScript1.2">
    function isgtZero(oForm, oTag, dValue){
    var tmp = dValue.substring(1,99) - 0; // strip out the $ and convert to
    numeric datatype
    if( tmp > 0 ) return true; // else returns false
    }

    </script>
    <body>
    <cfform method="POST" action="cfform_action.cfm">
    <cfinput name="dollarField" onvalidate="isgtZero" message="Must be greater
    than zero" value="$400">
    <input type="Submit">
    </cfform>

    gclausen Guest

  4. #3

    Default Re: SOS! To validate if form field entered by user isvalid number (not a negative value)

    gclausen,

    thanks for helping, I am sorry but I am not allow to use Javascript. Only CFML...any clue?

    Thanks again...
    Regards,
    Design in need of help. :confused;
    design in progress Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139