How can I change a field required attribute using jquery ?
I want to know if a required field is automatically not required just by hiding it or hidding his parent div ?
I use this jquery code for that :
My $(“#x_etabp_classe_redoublee_id”) is in a div $(“.etabp_classe_redoublee_id”). By hiding this div, is my field $(“#x_etabp_classe_redoublee_id”) automatically not required or should I handle requierement by code ?
You should not set the field as required in such case, you better use client side Form_CustomValidate event to validate the field if it is not hidden by .hide().
Hi,
After several attempts, I still can’t find a solution to my problem. I’m using custom template to manage my form, which contains several pages, and my HTML code looks like this (just the second page):
I also use .hide() to hide fields conditionally. My fields are hidden, but are still required, so the form can’t be posted.
My four fields
x_apporteur_affaire_id
x_origine_personnel_id
x_origine_prof_id
x_origine_autre
are all set to required in “Edit tag->validation” (required checked) and I hope them to be not required when hidden by .hide();What’s wrong with my code ?I’ve tried using client side Form_CustomValidate event but I don’t really want to validate my fields, but rather make them required or not depending on the value of canal = $(“#x_origine_connsce_etab”).val();
If you are using Custom Template for Multi-Page, then make sure you have already included all the Tabs/Pages into your Custom Template. It won’t work if you only include a few of them.
hi,
Yes, all pages are included and the form is displayed correctly with all fields.
I’ve just posted the html and script for page_2 so as not to make my post too long.
Hi,
After a few simple tests on a small single-page form, I noticed that the “required” is not handled by phpmaker in custom templates when fields are hidden by .hide().
I therefore opted for custom management in Form_CustomValidate event.
Thanks !