I have a form with two submit buttons. "Submit" and "Save and Finish Later".
When I click "Submit", all fields are required. When "Save and Finish Later" is clicked, none of the fields are required.
To accommodate this, I have a custom JavaScript file that I include via Load JS. All of the form validation is done in this script by using addClass() and removeClass() to add "validate['required']", "validate['group:"+id+"']", and "validate['tooltip']" as needed.
Everything works great except for one piece. When I remove "validate['group:"+id+"']", the change does not seem to register. Searching the forum, it looks like I would need to use .dispose() in previous versions. Essentially, even though I call removeClass(), it still flags it as not having an option selected when it in fact does.
Below is a sample of that file. If you want to see the whole file, please let me know and I can PM it to you. I have a feeling that after I "removeClass()", I need to call something to make it work.
Thank you!
When I click "Submit", all fields are required. When "Save and Finish Later" is clicked, none of the fields are required.
To accommodate this, I have a custom JavaScript file that I include via Load JS. All of the form validation is done in this script by using addClass() and removeClass() to add "validate['required']", "validate['group:"+id+"']", and "validate['tooltip']" as needed.
Everything works great except for one piece. When I remove "validate['group:"+id+"']", the change does not seem to register. Searching the forum, it looks like I would need to use .dispose() in previous versions. Essentially, even though I call removeClass(), it still flags it as not having an option selected when it in fact does.
Below is a sample of that file. If you want to see the whole file, please let me know and I can PM it to you. I have a feeling that after I "removeClass()", I need to call something to make it work.
function validate_form_fields(what_button){
makeRequiredRadio(what_button, jQuery(".industry_type_radio"), "10");
makeRequiredRadio(what_button, jQuery(".type_of_business"), "38");
}
function makeRequiredRadio(what_button, el, id){
var req = "validate['group:"+id+"']";
if(what_button == 'submit'){
jQuery(el).addClass(req);
} else {
jQuery(el).removeClass(req);
}
}
Thank you!