Page 1 of 1

Dropdown selection onchange condition of required field

Posted: Tue Sep 13, 2022 4:42 pm
by ahad

//dropdown field.…File status (Approved,Pending)
// Required field …. Approval id and date


$("#x_File_Status").change(function() {

  const x_File_Status = this.value;

  if (#x_File_Status == 'Approved') {

    $("#r_Approval ID").prop('required', true);

                $("#r_Date").prop('required', true);

  } else {

    $("#r_Approval ID").prop('required', false);

                $("#r_Date").prop('required', false);

  }

});

Its not worked


Re: Dropdown selection Onchange condition of Required field

Posted: Tue Sep 13, 2022 6:51 pm
by mobhar

Just press F12 from the browser, and check whether any Javascript error message from Console section.


Re: Dropdown selection Onchange condition of Required field

Posted: Sat Oct 01, 2022 3:02 am
by ahad

Please suggest on client script location for apply of this condition.

$("#x_fieldA").change(function() {
if (this.value == "1") {
$('#x_fieldB').attr("required", true);
} else {
$('#x_fieldB').attr("required", false);
}
});

Re: Dropdown selection onchange condition of required field

Posted: Sat Oct 01, 2022 10:12 am
by arbei

You should put your code at Startup Script of that page (not global).


Re: Dropdown selection onchange condition of required field

Posted: Sat Oct 01, 2022 11:44 pm
by ahad

Thanks following the code using in edit page working awesome with out any error.