Categories | Question details Back To List | ||
Problem with IE Hi, I am using IE 7.0 I have a HTML form, which has D HTML combo box with auto complete mode. I want to validate the D HTML combo box before submit the HTML FORM. I use below code to validate the D HTML combo, but it is not working with IE7.0 1. if (document.forms[0].comboName.value == "" ) alert("value is empty"); 2. if ( document.getElementById("comboName").value == "" ) alert("value is empty"); The above two method is not working with IE, but it works with Mozilla Firefox. Answer posted on Nov 14, 2007 02:05 The element of combo, which stores value has the same name as specified in constructor ( or same as name of select from which it was created ) if (document.forms[0].comboName.value == "" ) alert("value is empty"); must work for both IE and FF document.getElementById("comboName").value == "" must not work in any browser ( still may work because some browsers threat name and ID equal ) Also you can get current value directly from combo if (combo.getActualValue()=="") ... If problem still occurs for you - please provide any kind of sample where problem can be reconstructed. |