Dear Support,
I'm using CFv5. Is it possible to do "If Then style validation"? The problem I have to solve is according to the next situation:
I have two components, one dropdown and one text box. When the user choices YES in the dropdown then the text box has to be required. If the user choices NO then the field has to be blank and read only.
How can I do this?
Thanks in advance
I'm using CFv5. Is it possible to do "If Then style validation"? The problem I have to solve is according to the next situation:
I have two components, one dropdown and one text box. When the user choices YES in the dropdown then the text box has to be required. If the user choices NO then the field has to be blank and read only.
How can I do this?
Thanks in advance
Hi Milton,
Yes, so you can simply use the "events" section under the "Dropdown" settings, and in the "function" box write "enable_validation" when the value is "yes", and "disable_validation" when the value is "no".
Now, assuming your text box field id is "text1", please add a "Load JS" action to your form, and add this code:
Regards,
Max
Yes, so you can simply use the "events" section under the "Dropdown" settings, and in the "function" box write "enable_validation" when the value is "yes", and "disable_validation" when the value is "no".
Now, assuming your text box field id is "text1", please add a "Load JS" action to your form, and add this code:
function enable_validation(){
$("#text1").addClass('validate["required"]');
$("#text1").data("gvalidate_rules", ["required"]);
}
function disable_validation(){
$("#text1").removeClass('validate["required"]');
}
Regards,
Max
This topic is locked and no more replies can be posted.