我有两个文本框(pass1和pass2)。我希望隐藏pass2,并且仅当在pass1中输入某些内容时才显示。如果pass1为null,则Pass2应该隐藏。
最佳答案
<script type="text/javascript">
function checkVisibility() {
var pass1 = document.getElementById('pass1');
var pass2 = document.getElementById('pass2');
if (pass1.value.length > 0) {
pass2.style.visibility = 'visible';
} else {
pass2.style.visibility = 'hidden';
}
}
</script>
<input id="pass1" type="password" onkeyup="checkVisibility()" />
<input id="pass2" type="password" style="visibility: hidden;"/>