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

Question

Question

Toggle field to Required/Not Required

asked on November 17, 2016

Based on a radio button selection, a drop down box should be either Required or Not Required.  I used the attached code, but it allows me to submit a form without making a drop down selection even if the radio button option needing a selection is checked.  I think I may be missing adding something to CSS for .driver and .drivertype, but I'm not sure what that may be.  Thank you

 

0 0

Replies

replied on November 17, 2016

Have you tried using field rules show/hide based on radio button with 2 dropdowns one required and other not required?

2 0
replied on November 17, 2016

Maybe your code does not work, do you see the * appear when you select the button.

 

because if it is a radio button, I think your code is wrong. because input apply to input text field. I believe.

replied on November 17, 2016 Show version history

Take a look of my code I did for a Customer and see if this could give you hint to fix yours

 

 

 $('#q152 input').change(function () {
        if ($('#q152 input[value="Manual"]:checked').length > 0) {
            $('#q125').hide();
            $('.AccountInfo input').removeAttr('readonly');
            if (!$('.FieldReq input').prop('required')) {
                $('.FieldReq label, .FieldReq2 label').append('<span class="cf-required">*</span>');
                $('.FieldReq input,.FieldReq2 input').attr('required', 'True');
                //$('.FieldReq2 label').append('<span class="cf-required">*</span>');
                // $('.FieldReq2 input').attr('required', 'True');
            }
            $('.OrderInfo input').removeAttr('readonly');
            $('.Submit').removeAttr('disabled');
            $('#q126').hide();
        } else {
            $('#q125').show();
            $('.AccountInfo input').attr('readonly', 'True');
            $('.FieldReq span.cf-required').remove();
            $('.FieldReq input').removeClass('required').removeAttr('required');
      $('.FieldReq2 span.cf-required').remove();
            $('.FieldReq2 input').removeClass('required').removeAttr('required');
            $('.OrderInfo input').attr('readonly', 'True');
            $('.Submit').attr('disabled', 'disabled');
        }

 

0 0
replied on November 18, 2016

Thank you for the responses.  I appreciate it.  After reviewing Rene's code, I have tweaked mine a little.  However, it is still allowing a form submit without an entry in the Driver drop-down - even when it should be required.  The radio button defaults to Employee so the Driver drop-down should be set to required upon form load.  Anytime the radio button is changed, the Driver drop-down required attribute should be updated accordingly.

 

0 0
replied on November 21, 2016

As a follow up and closure to this question...Per Junald's suggestion, I was able to mark the field as Required on the form and set up Field Rules to Show/Hide the fields based on the value of the Radio Button.  (Hiding/Showing the field using Javascript had no effect on the Required indicator.  The result being that if the field was hidden, an entry was still required.)  Using Field Rules allowed for the field to be Hidden and not Required OR Shown and Required.

0 0
replied on January 6, 2023

Validate field as required or optional using field rules is supported in new form designer with Forms 11 Update 3.

You can see other changes of Forms 11 Update 3 from  https://support.laserfiche.com/kb/1014413/list-of-changes-for-laserfiche-forms-11-update-3 and get Forms 11 Update 3 from Laserfiche 11 package  https://support.laserfiche.com/kb/1014263/software-versions-and-fixes-included-in-the-laserfiche-11-download-package.

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

Sign in to reply to this post.