Avatar of Bruce Gust
Bruce Gust
Flag for United States of America

asked on 

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

Here's my Contact form:

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:

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

Open in new window

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


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'

Open in new window

...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?

Avatar of undefined
Last Comment

8/22/2022 - Mon