Kakao
05-03-2006, 08:13 PM
When I trigger the onchange event clicking on the other input field the focus() and select() methods (used alone or combined) in the validate() function works, but when I use the tab key to trigger the onchange event they does not work. Why? What can be done? Using FF 1.0.8
<html>
<script type="text/javascript">
function validate(obj) {
if (obj.value > 2) {
alert('must be <= 2');
obj.focus();
obj.select();
}
}
</script>
<body>
<input type="text" id="a" onchange="validate(this);" value="1">
<input type="text" id="b" onchange="validate(this);" value="2">
</body>
</html>
Regards, Kakao
Works in Opera 8.52
<html>
<script type="text/javascript">
function validate(obj) {
if (obj.value > 2) {
alert('must be <= 2');
obj.focus();
obj.select();
}
}
</script>
<body>
<input type="text" id="a" onchange="validate(this);" value="1">
<input type="text" id="b" onchange="validate(this);" value="2">
</body>
</html>
Regards, Kakao
Works in Opera 8.52