0
Answer

validation on dropdown inside grid view through javascript

CODE CODE

CODE CODE

10y
1.3k
1
hello

i need to put validation on dropdown inside gridview ...tyhe validation should check on button click outside the grid

i already use the below code but it doesn't work  for a single drop down

 <script type="text/javascript">
     function validate() {
         var flag = true;
         var dropdowns = new Array(); //Create array to hold all the dropdown lists.
         var gridview = document.getElementById('<%=Grid_acnthead_pstin.ClientID%>'); //GridView1 is the id of ur gridview.
         dropdowns = gridview.getElementsByTagName('select'); //Get all dropdown lists contained in GridView1.
         for (var i = 0; i < dropdowns.length; i++) {
             if (dropdowns.item(i).className == "ddl_budgetgroup" && dropdowns.item(i).value == 'BudgetGroup') //If dropdown has no selected value
            // if (dropdowns.item(i).value == 'BudgetGroup') //If dropdown has no selected value
             {
                 flag = false;
                 break; //break the loop as there is no need to check further.
             }
         }
         if (!flag) {
             alert('Please select value in each dropdown');
         }
         return flag;
     }
</script> 



actually mry my gridview has 4 column and all the four column contains dropdown.. and i have to put validation for all the 4 dropdowns..



please give me any idea how to access it


Thanks in adveance  :)