Last active
October 25, 2017 18:02
-
-
Save salsalabs/a40773efaab7c31722adffd3611feb47 to your computer and use it in GitHub Desktop.
Solution to hide the Middle Name input field on the additional fields step in Actions
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 type="text/javascript"> | |
/*This script will hide the Middle Name field when it is requested by the legislator | |
In its place the script will submit a blank space for the middle name.*/ | |
$(document).ready(function(){ | |
// select the target node | |
//#mainForm only appears on the additional fields step | |
var target = document.getElementById('mainForm'); | |
// create an observer instance | |
var observer = new MutationObserver(function(mutations) { | |
mutations.some(function(mutation) { | |
if ($("#webformInput").length > 0) { | |
if ($("#MIDDLE_NAME").length > 0) { | |
//Change the Middle Initial value to be a blank space and hide the field. | |
$("#MIDDLE_NAME").val(" "); | |
$("#MIDDLE_NAME").hide(); | |
$("label[for='MIDDLE_NAME']").hide(); | |
}//end if #MIDDLE_NAME | |
//stop observing we're done break out of the loop | |
observer.disconnect(); | |
return true; | |
}//end if #webformInput | |
});//end mutations.some | |
});//end MutationObserver | |
// configuration of the observer: | |
var config = { childList: true, subtree: true }; | |
// pass in the target node, as well as the observer options | |
observer.observe(target, config); | |
});//end $(document).ready | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment