We noticed you're using an ad blocker

Our website is made possible by displaying online advertisements to our visitors. Please consider supporting us by disabling your ad blocker.

Laravel Simple Captcha

world cup 2022

FootballDesk

Get update standing EPL, UEFA, LaLiga and more

Get Now

Captcha is the most used technique for preventing spam in form submission. The Laravel Simple Captcha package will help you to prevent spam form submission. It's a really simple and lightweight Laravel package for captcha.

Features of Laravel Simple Captcha

  • Lightweight
  • Simple & easy to use
  • Support Laravel version >=5
  • Captcha validation rules
  • Customizable

 

Installation

composer require haruncpi/laravel-simple-captcha

 

Usages

Use the getCaptchaBox method, In the form where you need to add captcha.

{!!getCaptchaBox()!!}

Optional: You can change the captcha answer input box name. By default, it is _answer

{!!getCaptchaBox('txtAnswer')!!}

Example

<form action="" method="POST">
    @csrf
    
    <div class="form-group">
        <label for="name">Name</label>
        <input type="text" class="form-control">
    </div>
    <div class="form-group">
        <label for="email">E-mail</label>
        <input type="text" class="form-control">
    </div>
    
    <div class="form-group">
    {!!getCaptchaBox()!!}
    </div>

    <button class="btn btn-sm btn-default">Submit</button>
</form>

 

Custom Captcha Box

For adjusting the captcha box in your markup, you can make the captcha box using the getCaptchaQuestion method.

<p>Captcha</p>

<input name="_answer" type="number">

 

Validation

Use simple_captcha validation rules where you handle the request.

public function handleForm(Request $request)
{
     $request->validate([ '_answer' => 'required | simple_captcha' ]);
}

 

Done! our simple captcha is now ready to use.

 

Share on




Related Post - Latest Post


Tinkerpad - A minimal Laravel code editor

Laravel Query Log

Laravel Jetstream tutorial

Laravel User Activity

Laravel Breeze - Starting with Laravel has been easy!

Laravel API mailer