Skip to main content
Known Participant
June 20, 2008
Question

Enable / Disable cfform validation.

  • June 20, 2008
  • 4 replies
  • 1134 views

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.
This topic has been closed for replies.

4 replies

Legend
June 30, 2008
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.
jjayAuthor
Known Participant
June 26, 2008
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.
Participating Frequently
June 26, 2008
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
jjayAuthor
Known Participant
June 26, 2008
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
Participating Frequently
June 26, 2008
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
Participating Frequently
June 26, 2008
You can actually validate the fields rather than using the onSubmit of cfform.
E.g:- Use the validate parameter in the cfinput