Home > other >  Laravel Login set validation message
Laravel Login set validation message

Time:09-17

I have captcha in login I need to set message to the rule

in LoginController

 /**
     * Validate the user login request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return void
     *
     * @throws \Illuminate\Validation\ValidationException
     */
    protected function validateLoginWithCaptcha(Request $request)
    {
        $request->validate([
            $this->username() => 'required|string',
            'password' => 'required|string',
            'captcha' => 'required|captcha_api:'. request('key') . ',math'
        ]);
    }

If I enter invalid captcha it is messaging

validation.captcha_api

I want to set the message rule

How do I set it?

I tried in Blade file like this

             @if($errors->has('validation.captcha_api'))

      <div class="alert_container">'<div class="alert alert-danger"><div class="alert_message_list"><ul><li>Invalid Captcha!</li></ul></div></div></div>

@endif

Not working

CodePudding user response:

@error('captcha')
 <div class="alert_container">'<div class="alert alert-danger"><div class="alert_message_list"><ul><li>Invalid Captcha!</li></ul></div></div></div>
                    @enderror

CodePudding user response:

I prefer you to use this package its easy to install and use, and you can read the instructions

https://github.com/anhskohbo/no-captcha

  • Related