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

Enable / Disable cfform validation.

New Here ,
Jun 19, 2008 Jun 19, 2008

Copy link to clipboard

Copied


I am using cfform for a CC payment form, and validating the CC number etc.. with the cfform "validate=credicard" paramater. This is all fine as usual.

I have a toggle in my form to show or hide particular fields depending on a radio button selected (Pay CC or Bank Tfr). If the CC payment fields are hidden (user has selected to pay by Bank Tfr), I don't want the validation for those fields to run. If they select CC payment, the validation should run. Validation is onSubmit.

I am trying to find a way of disabling or re-enabling the validation on given cfform fields. Have scoured the net, forums etc.. but just can't find anything.

Does anyone know how this could be acheived?

Many Thanks in advance.
TOPICS
Advanced techniques

Views

969

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
Explorer ,
Jun 26, 2008 Jun 26, 2008

Copy link to clipboard

Copied

You can actually validate the fields rather than using the onSubmit of cfform.
E.g:- Use the validate parameter in the cfinput

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
New Here ,
Jun 26, 2008 Jun 26, 2008

Copy link to clipboard

Copied

Hi AbhiFusion, thanks for your suggestion, but I don't know if I am sure I understand what you are suggesting. Could you elaborate?

Thanks

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
Explorer ,
Jun 26, 2008 Jun 26, 2008

Copy link to clipboard

Copied

Just for example:-
You must be using a text field so that user can enter the credit card number. And this is what you want to validate. In this case use following code

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
New Here ,
Jun 26, 2008 Jun 26, 2008

Copy link to clipboard

Copied

That's exactly what I am doing.

My question though is how can I turn this validation OFF. I am validating the field, but if the user selects to pay by an option other than Credit Card, I need to be able to 'turn off' the validation process so that I can submit the form with this field empty.

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
Explorer ,
Jun 26, 2008 Jun 26, 2008

Copy link to clipboard

Copied

In that case, you can use the parameter onValidate and use a Javascript function which would check that if radio button is selected then what validation it has to do.
Ofcourse you would then need to embed the creditcard validation code in the javascript

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 ,
Jun 30, 2008 Jun 30, 2008

Copy link to clipboard

Copied

LATEST
A porr mans way to fix it would be to have you radio button onClick event set the value of the CC field to "0" the same time you hide or disable the field and set it to "" when you make it visible or enable the field.

"0" passes the Adobe CC check.

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