manish kedar

manish kedar

  • NA
  • 229
  • 11.6k

validate the gridview control

Dec 13 2017 5:43 AM
Hello Sir,
 
I have a girdview, in that i have textbox and dropdownlist.
 
I want to validate that control on client side with checkbox if checkbox is checked then check the textbox is empty and dropdownlist also. and i have only one button in bottom.
I done that validation but whenever checkbox is checked and textbox not empty then also alert msg is showing..and also how to get client id of particular row....
 
Please help me.
 
the code is :--
 
on button click....
  1. function Validate() {  
  2. var chkBoxList = document.getElementById('<%=gv_Toppers.ClientID %>');  
  3. var chkBoxCount = chkBoxList.getElementsByTagName("input");  
  4. for (var i = 0; i <chkBoxCount.length; i++) {  
  5. if (chkBoxCount[i].checked) {  
  6. var txtMarks = document.getElementById('txtMarks');  
  7. var ddlRank = document.getElementById('ddlRank');  
  8. if(txtMarks=="" || txtMarks== null)  
  9. {  
  10. alert("Please Enter Student Marks!!!");  
  11. return false;  
  12. }  
  13. if (ddlRank.value == "0" || ddlRank.value == "Select Rank") {  
  14. alert("Please Select Student Rank!!!");  
  15. return false;  
  16. }  
  17. }  
  18. }  
  19. }  

Attachment: myQ.rar

Answers (1)