Validation for dropdowns created dynamically using javascript
<p>I have few dynamic dropdowns that the created on change of a dropdownlist, on submit of addbutton I need to make sure that none of the dynamic dropdowns are empty. The default value of dynamic dropdowns is empty.</p>

<p>I tried the code below , but it does'nt seem to get the selected value of the dropdown.</p>

<pre><code> DropDownList MynewDdlList = new DropDownList();
 ddllist.ID = "ddl" + name;
 ddllist.Width = 100;
 ddllist.BorderColor = System.Drawing.Color.Red;
 ddllist.Attributes.Add("IsMandatory", "Y");
</code></pre>

<p>Below is my javascript function </p>

<pre><code>function validateInput() {
var ddlTextBox = document.getElementsByTagName("select");
 var returnValue = 1;

for (j = 0; j &lt; ddlTextBox.length; j++) {
    if (ddlTextBox[j].type =="text" &amp;&amp; ddlTextBox[j].getAttribute("IsMandatory")=="Y" &amp;&amp; ddlTextBox[j].selectedIndex == "") {
        returnValue = 0;
    }
}
if (returnValue == 0) {
    alert("Validation Failed");
    return false;
}
else {
    alert("Validation Success");
    return true;
}
}
         Please help me with the correct syntax for this  ddlTextBox[j].selectedIndex == "")    
</code></pre>
