Dropdown selection onchange condition of required field

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
ahad
User
Posts: 22

Dropdown selection onchange condition of required field

Post 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


mobhar
User
Posts: 11660

Post by mobhar »

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


ahad
User
Posts: 22

Post 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);
}
});

arbei
User
Posts: 9284

Post by arbei »

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


ahad
User
Posts: 22

Post by ahad »

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


Post Reply