I have four text fields in my form. When the user enters some value in any one of the fields, I want to disable other text fields. How can I get this to work in both Netscape and IE?
Created May 7, 2012
Ravi Verelly The below code works in Netscape and IE:
<html> <head> <title>form1</title> <script language="JavaScript"> var flg = false; function chk(){ var field = window.document.f1; if (field.t1.value.length==0&& field.t2.value.length==0&& field.t3.value.length==0&& field.t4.value.length==0) flg=false; } function disablef(which){ chk(); if(flg&&which.value.length==0) which.blur(); else flg = true; } </script> </head> <body> <form name="f1"> <input type="text" name="t1" onfocus="disablef(this);">
<input type="text" name="t2" onfocus="disablef(this);">
<input type="text" name="t3" onfocus="disablef(this);">
<input type="text" name="t4" onfocus="disablef(this);">
</form> </body> </html>