• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Activating validate on cfinput only when checkbox is selected

New Here ,
Dec 12, 2007 Dec 12, 2007

Copy link to clipboard

Copied

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.
TOPICS
Advanced techniques

Views

355

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 13, 2007 Dec 13, 2007

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Dec 20, 2007 Dec 20, 2007

Copy link to clipboard

Copied

LATEST
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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation