Click here to Skip to main content
15,886,810 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, I want to validate my page which has there are 5 text boxes and 4 checkboxes,each refer to text box,
i have not selected checkbox list, now i have check neither text box is left empty, and atleast 1 checkbox is selected, how to achieve this
Posted
Comments
Sinisa Hajnal 21-Jan-16 5:53am    
Clarify: you do not have checkboxlist, but you do have four checkboxes. Right? And you need to check that at least one checkbox is checked and all textboxes have to be filled?

1 solution

You can use JavaScript to validate each control separately, you need to get all textboxes and checkboxes to validate it.
see below snippet
JavaScript
<script language="Javascript">
function validate()
{
   if (!(Checkbox1.checked || Checkbox2.checked || Checkbox3.checked || Checkbox4.checked))
      {
          alert("Please check any of the checkboxes");
          return false;
      }

   if (!(Txt1.Text != "" || Txt2.Text != "" || Txt3.Text != "" || Txt4.Text != ""))
      {
          alert("Please check any of the Textboxes");
          return false;
      }
}
</script>
 
Share this answer
 
Comments
Member 11360268 22-Jan-16 0:38am    
hello, thank you for reply did the same thing.
koolprasad2003 22-Jan-16 6:23am    
Mark the solution as resolved, if it resolve your issue

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900