Add Captcha On Laravel Forms

To add Captcha to Laravel form without any API Connection

Install mews/captcha

composer require mews/captcha

Find the providers key in config/app.php and register the Captcha Service Provider. for for Laravel 5.1+

‘providers’ => [


This content originally appeared on DEV Community and was authored by Arman Rahman

To add Captcha to Laravel form without any API Connection

Image description

Install mews/captcha

composer require mews/captcha

Find the providers key in config/app.php and register the Captcha Service Provider. for for Laravel 5.1+

'providers' => [
        // ...
        Mews\Captcha\CaptchaServiceProvider::class,
    ]

Find the aliases key in config/app.php.

'aliases' => [
        // ...
        'Captcha' => Mews\Captcha\Facades\Captcha::class,
    ]

publish mews/captcha by running -

$ php artisan vendor:publish

Add this to .env to disable captcha

CAPTCHA_DISABLE=true

Add this on laravel blade

 //register.blade.php
    <img src="{{ captcha_src() }}" alt="captcha">
        <div class="mt-2"></div>
        <input 
            type="text" name="captcha" class="form-control @error('captcha') is-invalid @enderror" placeholder="Please Insert Captch"
            >
         @error('captcha') 
         <div class="invalid-feedback">{{ $message }}</div> @enderror 

in controller validate like this -

$request->validate([
'captcha' => 'required|captcha'
],[],[
     'captcha.required' => 'Captcha is required',
     'captcha.captcha' => 'Captcha is invalid',
])


This content originally appeared on DEV Community and was authored by Arman Rahman


Print Share Comment Cite Upload Translate Updates
APA

Arman Rahman | Sciencx (2024-08-25T04:40:56+00:00) Add Captcha On Laravel Forms. Retrieved from https://www.scien.cx/2024/08/25/add-captcha-on-laravel-forms/

MLA
" » Add Captcha On Laravel Forms." Arman Rahman | Sciencx - Sunday August 25, 2024, https://www.scien.cx/2024/08/25/add-captcha-on-laravel-forms/
HARVARD
Arman Rahman | Sciencx Sunday August 25, 2024 » Add Captcha On Laravel Forms., viewed ,<https://www.scien.cx/2024/08/25/add-captcha-on-laravel-forms/>
VANCOUVER
Arman Rahman | Sciencx - » Add Captcha On Laravel Forms. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/08/25/add-captcha-on-laravel-forms/
CHICAGO
" » Add Captcha On Laravel Forms." Arman Rahman | Sciencx - Accessed . https://www.scien.cx/2024/08/25/add-captcha-on-laravel-forms/
IEEE
" » Add Captcha On Laravel Forms." Arman Rahman | Sciencx [Online]. Available: https://www.scien.cx/2024/08/25/add-captcha-on-laravel-forms/. [Accessed: ]
rf:citation
» Add Captcha On Laravel Forms | Arman Rahman | Sciencx | https://www.scien.cx/2024/08/25/add-captcha-on-laravel-forms/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.