Is there a correct way to approach that on Chronoforms v6, or should I use javascript+PHP?
Forums
Validation of hidden element
Is there a correct way to approach that on Chronoforms v6, or should I use javascript+PHP?
The next update has a new validation "disabled" setting, this lets you set the validation requirements but keep it inactive until its enabled using a field event "Enable validation".
Best regards,
Max
But what if I need to enable/disable the validation of an element based on some conditions inside a JS function? The Enable Validation inside the Events tab is a direct approach, but there are times where I do need to call a function first and that function will know if the validaiton should be enabled or not. What do you think?
Apologies for the late reply!
I've tested the 6.0.9 version and the new option to Disable the validation works just for the JavaScript. But after submiting the form, the action Validate Fields (the default one) is asking to fill the field, even if it is still with the Disable option checked.
You will need to skip the disabled fields in the "Validate fields" action settings.
But what if I need to enable/disable the validation of an element based on some conditions inside a JS function? The Enable Validation inside the Events tab is a direct approach, but there are times where I do need to call a function first and that function will know if the validaiton should be enabled or not. What do you think?
Possible with a core change, if you still need this then let me know and I will tell you how to get it done.
Best regards,
Max
Possible with a core change, if you still need this then let me know and I will tell you how to get it done.
I don't like this approach because I don't like changing original code. But thanks.
You will need to skip the disabled fields in the "Validate fields" action settings.
I didn't see an option for that. Or do you mean manually writing the field name on the textbox? That would just disable the submit validation even if the field is enabled. I'm still trying to understand the most 'automatic' way to do that.
On v5 if a field was disabled, then it would automatticaly skip the submit validation. So I could write a JS function to enable/disable the field and that would do the trick, do you know?
I didn't see an option for that. Or do you mean manually writing the field name on the textbox? That would just disable the submit validation even if the field is enabled. I'm still trying to understand the most 'automatic' way to do that.
On v5 if a field was disabled, then it would automatically skip the submit validation. So I could write a JS function to enable/disable the field and that would do the trick, do you know?
I get what you mean, the automatic processing can be added but it may take sometime, the current easy solution is to disable checking the field totally under the "Validate fields" action.
This way you disable the server validation, but the js validation is disabled easily using the events section of your field.
Best regards,
Max
do you have a solution to your problem yet?
If yes: what is your solution?
I tested it with Chronoforms V. 6.0.19. And the problem is still available: if a entry field is configured as required and the entry field is hidden, then I cannont submit the form (like it was possible with CF5).
Regards,
Hans-Christian

jQuery('.ui.form').form('remove field', 'fieldname');
And to programmatically add the validation back
jQuery('.ui.form').form('add fields', jQuery('.ui.form').form('get field', 'field_name'));Although that second one is probably wrong.
https://semantic-ui.com/behaviors/form.html#/settings