Mahmoud Santos

23 Feb 2022

How can I validate recaptcha in Livewire class ??

Laravel

Hello guys, Please anyone can help me to do Recaptcha in the Livewire class?

I recently moved my contact form to a livewire component and everything works except my google Recaptcha it no longer works.

// Validate contact info
 $this->validate([
 'name' => 'required|min:4|max:30',
 'email' => 'required|email',
 'subject' => 'required|min:5|max:100',
 'message' => 'required|min:30|max:500',
 'g-recaptcha-response' => config('services.recaptcha.key') ? 'required|recaptcha' : 'nullable',
 ]);

component form

<!-- google recaptcha -->
 @if(config('services.recaptcha.key'))
 <div class="form-group">
 <div wire:model.defer="g-recaptcha-response" class="g-recaptcha"
 data-sitekey="{{config('services.recaptcha.key')}}">
 </div>
 @error('g-recaptcha-response')
 <span class="invalid-feedback mt-3" role="alert">
 <strong>{{ $message }}</strong>
 </span>
 @enderror
 </div>
 @endif

 

Comments

Yasen Sayed

23 Feb 2022

Best Answer

best answer

If you know Arabic I made a small video to describe how you can use it.

You should follow the next steps in the video, I hope these are will help you.

 

//www.youtube.com/watch?v=TFJCHny_VgU&ab_channel=LARATRICKS

Replies

Mahmoud Santos

23 Feb 2022

Thank you, that was really helpful 

© 2024 Copyrights reserved for web-brackets.com