Hello
I have two fields A and B I want to grey out field B when field A is entered and the opposite, do you know how to do it?
Thank you
Grey one field according to another
Re: Grey one field according to another
Hi,
as this is very specific the answer can not be clear.
What kind of fields do you have?
If you say gray out, does it mean that you want to make that field read-only?
in general, with javascript (jquery) you can a "on change" event on you fields and react accordingly, e.g.
Add you style
as this is very specific the answer can not be clear.
What kind of fields do you have?
If you say gray out, does it mean that you want to make that field read-only?
in general, with javascript (jquery) you can a "on change" event on you fields and react accordingly, e.g.
Code: Select all
$j(document).ready(function() {
$j("#fieldA").on("input", function() {
if (j$(this).val().trim() !== "") {
$j("#fieldB").prop("disabled", true).addClass("greyed-out");
} else {
$j("#fieldB").prop("disabled", false).removeClass("greyed-out");
}
});
$j("#fieldB").on("input", function() {
if ($j(this).val().trim() !== "") {
$j("#fieldA").prop("disabled", true).addClass("greyed-out");
} else {
$j("#fieldA").prop("disabled", false).removeClass("greyed-out");
}
});
});
Code: Select all
<style>
.greyed-out {
background-color: #eee;
pointer-events: none;
}
</style>
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.