troubleshooting Question

How can I see if at least one of these checboxes has been checked?

Avatar of Bruce Gust
Bruce GustFlag for United States of America asked on
PHPLaravel
4 Comments1 Solution42 ViewsLast Modified:
Here's my Contact form:

checkbox
I want to ensure my user has selected at least one of the checkboxes. I know how to do it in JQuery, but I want to make use of the:

@if($errors->any())
						<div class="alert alert-danger">
							<ul>
								@foreach($errors->all() as $error)
									<li>{{ $error }} </li>
								@endforeach
							</ul>
						</div>
					@endif

...section of my blade, as opposed to a traditional "alert" box.

How?

In the past, I've done something like this:

$data = request() -> validate([
			'name'=> 'required',
			'email' => 'required',
			'occupation' => 'required',
			'address_1' => 'required',
			'city' => 'required',
			'state' => 'required',
			'postal_code' => 'required',
			'country' => 'required',
			'phone' => 'required', 
			'comments' => 'required'
		]);

...which works fine, as far as validating the input fields, but it doesn't give me the freedom to check the boxes like I need to as far as ensuring at least one has been checked.

How can I pull this off?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros