If at first you don't succeed, call it version 1.0

Contact Me

Sarvesh Kushwaha
Email : sarveshkushwaha@outlook.com

Total Pageviews

Powered by Blogger.

Saturday, 24 March 2012

Javascript vallidations or client side validatios


checkboxlist validation                                                                                                                                            

<script type = "text/javascript"> 


function GetSelectedItem() 

{ 

   var CHK = document.getElementById("<%=CheckBoxList1.ClientID%>"); 

   var checkbox = CHK.getElementsByTagName("input"); 

   var label = CHK.getElementsByTagName("label"); 

   for (var i=0;i<checkbox.length;i++) 

   { 

       if (checkbox[i-1].checked) 

       { 

           alert("Selected = " + label[i].innerHTML); 

       } 

   } 

   return false; 

} 

</script>  


textboxvalidation 



<script  type="text/javascript" language="javascript"  >    
                 function Validation() 
                 { 

                     if (document.getElementById("<%=TB1.ClientID%>").value.trim() == "")  
                     { 
                         document.getElementById("label").innerHTML = "*"; 
                         document.getElementById("<%=TB1.ClientID%>").focus(); 
                         return false; 
                     } 
                     else { 
                         document.getElementById("label").innerHTML = ""; 
                     } 
                     if (document.getElementById("<%=TB2.ClientID%>").value.trim() == "") { 
                         document.getElementById("label1").innerHTML = "*"; 
                         document.getElementById("<%=TB2.ClientID%>").focus(); 
                         return false; 
                     } 
                     else { 
                         document.getElementById("label1").innerHTML = ""; 
                     } 
                     return true; 
                 } 
                  
    </script> 


radiobuttonlist 


<script language="javascript" type="text/javascript"> 
     function ValidateRadioTable() { 
         var rb2 = document.getElementById('<%=Rbl_S4.ClientID%>'); 
         var radio_choice2 = false; 
         for (counter2 = 0; counter2 < rb2.length; counter2++) { 
             if (rb2[counter2].checked) { 
                 radio_choice2 = true; 
                 break; 
             } 
         } 
         if (radio_choice2 == false) { 
             alert("Please select Digi or maxis") 
             event.returnValue = false; 
             return false; 
         } 
         return false; 
     } 

</script>

0 comments:

Post a Comment