Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Mar 2013
    Posts
    16
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Cftext box accept only multiple on 0.25 values.

    hi,
    i got a problem.i have a cftext box.
    <cfinput type="text" name="abc" id="abc">

    it should accept 0.25 multiples means 0.25,0.50,0.75,1.00,1.25,1.50 like that.

    i have got requirement like this.

    15 Minutes - 0.25
    30 Minutes - 0.50
    45 Minutes - 0.75
    60 Minutes - 1.00
    75 Minutes - 1.25 and so on...


    can any one help me on this

  • #2
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 Posts
    Not sure if you can use CF's built-in validation for that. I usually use JavaScript for client-side validation. Are you validating on blur, change, or submit?

    Modulus should handle it. If the mod of any number equals zero, there is no remainder so it's evenly divisible.

    Code:
    df = document.forms['formname'];
    if(df.abc.value % .25 == 0){ alert('Multiple of .25');}
    else{alert('NOT a multiple of .25');}
    Also, even if you wait half an hour to cross-post, cross-posting is generally frowned upon in forums.
    Last edited by WolfShade; 03-14-2013 at 03:29 PM.
    ^_^

    If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
    *
    The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".

  • #3
    New Coder
    Join Date
    Mar 2013
    Posts
    16
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thank you

    i am validating on submit. can you please tel me where i have to write this code means with in the </form> tag or out side the tag...i am new to coldfusion.

  • #4
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 Posts
    What I suggested is 'pseudo-code', and just part of the function that could be used for client-side validation. Without knowing things like form name/id, etc., I can't really help any more than that.

    Basically, you could create a function between <script> and </script> tags which would be placed just prior to the closing </body> tag. If this is the only input that needs specialized validation, then you would make the function with just that one input in mind, so it would be a short script. Then give the cfform an onsubmit event that would check the value before submitting, and if it doesn't match what you need, "return false;" on the submit.

    But this is becoming a little more complicated than I think it needs to be. I wonder if CF's built-in validation might work with modulus. I'll check around.
    ^_^

    If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
    *
    The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".

  • Users who have thanked WolfShade for this post:

    kanna443 (03-14-2013)


  •  

    Posting Permissions

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