✔ 最佳答案
通常都是由onchange去call一些function, 跟著將r pass去其他functions
例如你想在第二個textfield show txttest的value
<script type="text/javascript">
function txtchanged() {
txttest = document.getElementById('txttest').value;
puttxt = document.getElementById('puttxt');
if (txttest.match(/......../)) {
puttxt.value = txttest;
} else {
puttxt.value = 'no';
}
}
</script>
<input type="text" id="txttest" onchange="txtchanged()" />
<input type="text" id="puttxt" />
每次txttest被改的時候,如果txttest多過或等於8個字
puttxt就會show txttest的value
如果txttest少過8個字
puttxt就會show "no"
2007-05-02 03:40:21 補充:
其實可以在body寫個message<script type="text/javascript"> function check_input() { var pass = document.getElementById('pass'); var display = document.getElementById('check_password');
2007-05-02 03:41:20 補充:
if (pass.value.length >= 8) { display.innerHTML = 'Password length ok'; } else { display.innerHTML = 'Please enter a longer password'; pass.focus(); } }
2007-05-02 03:41:45 補充:
</script>Password: <input type="password" id="pass" onchange="check_input()" /><span id="check_password" style="color: red"></span>
2007-05-02 03:44:23 補充:
效果可以在這裏見到:
http://kcw184.googlepages.com/a.html