My second form shows as soon as I type something in the input field, but I am not sure how to hide the second form if I remove the text from the input field. Any help is appreciated.
I have this code:
<input style="margin-right: 5px;" type="text6" name="outstanding1" id="outstanding"
onClick="document.getElementById('form2').style.display='';" />
<script>
var outstanding = document.getElementById("outstanding");
outstanding.onsubmit = function() {
document.getElementById("form2").style.display = "none";
};
</script>
2
Answers
Maybe you need something like this:
or maybe you can handle input changing by
onkeydown
functionIf the input
outstanding1
is near the form that needs to show/hide you can use the Next-sibling combinator or (as in the example) the Subsequent-sibling combinator. The inputoutstanding1
need the attributerequired
to validate/invalidate the formform01
.