2 Replies Latest reply on Dec 20, 2007 5:22 PM by Steve Sommers

    Activating validate on cfinput only when checkbox is selected

    Photoshare
      I am designing a credit-card entry form hat automatically checks the validity of an entered credit-card number. Using cfinput validate="creditcard" works fine, but I cannot figure out a way (maybe using Javascript) to turn off validation if the user selects "Gift Card" from either a drop-down menu or a checkbox. If I use two boxes then ultimately the credit-card field box will be left empty - also causing problems for the validation of that field.

      Any suggestions?

      Thank you.
        • 1. Re: Activating validate on cfinput only when checkbox is selected
          freakyAndFree Level 1
          Ok, here's a simple suggestion that might achieve what you're looking for:

          Script the 'gift card' checkbox so that when it's unchecked, the credit card input displays and when it's checked, the cc field is hidden. In the js where you hide the cc field, update its value to 4111111111111111. It will then pass the validation check just fine. Then you can just clear the value if the gift card checkbox is unchecked.

          Short-circuiting the auto-generated javascript validation would be a lot more complicated than simply supplying it with a value that passes validation.

          Make sense?
          • 2. Activating validate on cfinput only when checkbox is selected
            Steve Sommers Level 4
            quote:

            Originally posted by: freakyAndFree
            ...update its value to 4111111111111111.
            Unless the latest MX updated the creditcard validation logic, simply assigning a value of "0" passes the check, satisfies the required parameter and may be a little easier to work with during the action processing.