Hey, I was including an entity form here to my web form as additional action and I wanted to disable the field Other University and only enable it when the field Institute Name is set as "Others...". Is there any possible way to add the custom javascript to the entity form to achieve that? Thank you in advance!
Solved! Go to Solution.
Hi @Anonymous,
In your Entity Form's custom JS, use the below code - update for your actual field schemas.
If you want to clear & hide the value for any selection other than "Other..."
$(function () {
var $instName = $("#new_institutename);
$instName.change(function () {
if ($instName.val() === "1234567") { // use actual option set value for 'Other...'
$("#new_otheruniversity").closest("td").show();
} else {
$("#new_otheruniversity").val("").closest("td").hide();
}
}).change();
});
If you want to instead disable it:
$(function () {
var $instName = $("#new_institutename);
$instName.change(function () {
if ($instName.val() === "1234567") { // use actual option set value for 'Other...'
$("#new_otheruniversity").prop("readonly", false);
} else {
$("#new_otheruniversity").val("").prop("readonly", true);
}
}).change();
});
If you don't want to clear the value, you can leave off the .val("") part and just use .prop("readonly", true");
Hi @Anonymous,
In your Entity Form's custom JS, use the below code - update for your actual field schemas.
If you want to clear & hide the value for any selection other than "Other..."
$(function () {
var $instName = $("#new_institutename);
$instName.change(function () {
if ($instName.val() === "1234567") { // use actual option set value for 'Other...'
$("#new_otheruniversity").closest("td").show();
} else {
$("#new_otheruniversity").val("").closest("td").hide();
}
}).change();
});
If you want to instead disable it:
$(function () {
var $instName = $("#new_institutename);
$instName.change(function () {
if ($instName.val() === "1234567") { // use actual option set value for 'Other...'
$("#new_otheruniversity").prop("readonly", false);
} else {
$("#new_otheruniversity").val("").prop("readonly", true);
}
}).change();
});
If you don't want to clear the value, you can leave off the .val("") part and just use .prop("readonly", true");