Moz, onkeyup and readOnly problem |
The folowing code works improperly in FF. It supposes to make one of the textfields read-only if the other has some input in it. Works OK in IE, but in FF if I delete (with backspace) the input in one of the textfields, the other remains read-only... Why?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<script type="text/javascript">
function switchT(a,w){
var b = document.getElementById(w);
(a.value.length>0)?b.setAttribute('readOnly',true):b.setAttribute('readOnly',false)
}
</script>
</head>
<body>
<input id="txt1" type="text" onkeyup="switchT(this,'txt2')"><br>
<input id="txt2" type="text" onkeyup="switchT(this,'txt1')">
</body>
</html>
|
|
|
|
|