You are viewing limited content. For full access, please sign in.

Question

Question

Forms - Working with select objects in javascript

asked on September 30, 2016 Show version history

Working with select objects instead of input objects has some strange functionality. For example if I hide a select object, it only hides the select box but not the title. When I hide an input object, it hides the input and the title. When I change the required value of the select object it doesn't remove or add the red * like it does with inputs.

 

Example of hiding a select object.

 

$('.dir select').hide();

 

0 0

Replies

replied on October 3, 2016

Hello,

To hide title with select object, you can remove 'select' from your jQuery; just use id or class will hide both title and select object from the form.

About changing required value of select object and not removing or adding * issue, does it happen in Edit Forms page?? when you configure the select object??

Thank you! 

0 0
replied on October 3, 2016

Ah ok, that worked. I just need to remove the field requirement when hidden so that they can submit the form.

When I try to remove the requirement on a select field it doesn't seem to work.

$('.dir').hide();
$('.dir').prop('required', false);

I would rather just use the field rules to do this but the conditional fields are storing currencies, not numbers. Field rules only support basic number evaluations. 

If I use javascript to determine a number based on the currency and populate a hidden number field, the field rules ignore my hidden number field. I guess you can only use field rules for fields populated manually.

0 0
replied on October 4, 2016

Found it was just not removing the red * but you can submit without selecting anything. That is the important part.

0 0
replied on October 5, 2016

First of all, to do '.prop('required', false)', you might want to change the selector. dir class might not be the one that you want to update. If you go to 'CSS and JavaScript' page, you will be able to find out the id for the select object. Try with that id, instead of dir class. dir class is for both label and select object. And required property is only for select object, not for the label. 

And about the field rule, you can show or hide a certain field when the configured condition is satisfied. (I'm not sure about currency and number values that you mentioned above). If a required field is hidden by field rule, you will be able to submit the form even no value is selected for hidden required field. If a required field is shown by field rule, you will have to select a value for the required field to submit the form.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.