Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I have 4 check boxes, and wants to perform validation that at-least one should be checked before submitting the form.
Posted

You can implement the technique I explained on my Blog - ASP.NET CHECKBOXLIST CLIENT SIDE VALIDATION USING JAVASCRIPT[^].
 
Share this answer
 
Comments
Maciej Los 8-May-14 2:04am    
Self-reference, i like it!
Thanks Maciej Los. :)
why regex?
you can use client side validation using javascript or jquary
jQuery see if any or no checkboxes are selected[^]
and you may need do a server side validation, then
C#
CheckBox[] checkboxes = new CheckBox[] { CheckBox1, CheckBox2, CheckBox3, CheckBox4 };
if (!checkboxes.Any(c => c.Checked))
{
    // show error 
}
 
Share this answer
 
v3
Comments
Maciej Los 8-May-14 2:04am    
"Why Regex?" - very good question!
+5!
It has got nothing to do with regex, just use javascript to validate before submission
check-box-validation-for-atleast-one-check-box-should-cheked-in-asp-net[^]
 
Share this answer
 
v2
Comments
DamithSL 7-May-14 22:18pm    
my 5+ for client side validation
Peter Leow 7-May-14 23:31pm    
Thanks, DamithSL.
Maciej Los 8-May-14 2:03am    
+5
Peter Leow 8-May-14 2:42am    
Thanks Maciej.

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