Forums

Making field required or not dynamicly

dragoverd 19 Jul, 2014
Hi,

I have a form with a field "adresse" an a check box "Do you want to get the results by mail rather than e-mail ?". If the client check this checkbox the adresse's field become 'requiered' !

Is Chronoforms V5 capable to manage this ? How ?
Max_admin 17 Sep, 2014
Hi,

Sorry for the late reply, just found this post!

In order to add conditional validation to a field in cfv5, please try this code:

jQuery("#field_id").addClass("validate['required']");


Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
nicobond 03 Oct, 2014
I have a similar problem. In my form there's a dropdown field in which if the user select a value, another dropdown menu become required. How to do this? Where to put the code?
Max_admin 03 Oct, 2014
You will need to use the "Events" section in your dropdown, and set it to "function", then use the code above inside your function!

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
nicobond 03 Oct, 2014
Ok, I have edited my dropdown field by filling in the value from this dropdown the user has to select to trigger the event. Under the "Action" field I've selected "function" as you told me, in the field id, fn() or event field I've put the code jQuery("#field_id").addClass("validate['required']") and the field "Options list or ajax event" is empty.
I've replaced #field_id with the other dropdown id that must become required.
Is that correct?
GreyHead 03 Oct, 2014
HI nicobond,

Please see Max's post just before yours, this will need to be added to a Load JavaScript action in your forms On Load event together with the rest of the script to trigger the validation.

If you need help with that please post the names of the inputs and the condition that you want to use to enable/disable the validation.

Bob
Max_admin 06 Oct, 2014
Hi,

In the "fn", please add a function name, for example "add_validation"

Then in your load javascript action, define it:


function add_validation(el){
 jQuery("#field_id").addClass("validate['required']");
}
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.