Last active
October 11, 2021 13:40
-
-
Save grantholle/d1ff87f881376f4cf87f8d66e1fbb4a4 to your computer and use it in GitHub Desktop.
Missy jQuery help
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
// Keep everything scoped to this function | |
// Run on startup | |
$j(function() { | |
// Storing as a variable | |
const $fpCompl = $j('#fpcompl') | |
// Add any other 'editable' values you want to this array | |
const editable = [ | |
'No(AR)', | |
'Yes(DE)' | |
] | |
function fpCompComment () { | |
const value = $fpCompl.val() | |
// Check compliance value | |
if (editable.includes(value)) { | |
// make required and editable | |
// since we're returning here, the `else` isn't necessary | |
return $j('#fp_cmt') | |
.prop('readonly', false) | |
.prop('required', true) | |
.removeClass('disabled') | |
.addClass('required'); | |
} | |
// not editable not required | |
$j('#fp_cmt') | |
.val('') | |
.prop('readonly', true) | |
.prop('required', false) | |
.removeClass('required'); | |
}; | |
// Initial load. | |
fpCompComment(); | |
// Now set up listener for any changes in compliance | |
$fpCompl.on('change', fpCompComment); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Awesome - thank you so much - it is working now!