On an EditForm.aspx page I have a routine to hide/unhide a field based on the change of another field. It works fine on pageload, but I want to fire the change on the page itself if the user makes a change. What is the correct syntax to create the event? Thanks for the help!
$(document).ready(function () {
var statusField = SPUtility.GetSPField('Status');
var showOrHideField = function() {
var statusFieldValue = statusField.Controls.value.substr(0,statusField.Controls.value.search("\\|"));
if(statusFieldValue === 'New') {
SPUtility.HideSPField('Comment');
}
else {
SPUtility.ShowSPField('Comment');
}
};
showOrHideField();
// none of these options worked
$('#Status').bind ("change", function(){ showOrHideField(); });
$('#Status').trigger('change');
$('#Status').change(function(){ })
$('#Status'.Dropdown).on('change', showOrHideField);
});