greggilbert / recaptcha

[ABANDONED] reCAPTCHA Validator for Laravel 5
MIT License
714 stars 197 forks source link

Validation message is not shown #139

Open danifantom opened 7 years ago

danifantom commented 7 years ago

If I try to send the form without completing the captcha the form just reloads with no error messages. In the LoginController.php I have this

 protected function validateLogin(Request $request)
    {
        $this->validate($request, [
            $this->username() => 'required', 
            'password' => 'required',
            'g-recaptcha-response' => 'required|recaptcha',
        ]);
    }

I've even tried to change the validation message but nothing shows up

Askancy commented 7 years ago

Add this code to your view

@if(count($errors->all()) > 0)
  <div class="alert alert-danger" role="alert"> <p><b>Attenzione!</b></p>
    <ul>
      @foreach($errors->all() as $error)
        <li>{{ $error }}</li>
      @endforeach
    </ul>
  </div>
@endif
ihsanberahim commented 7 years ago

I used this

                        <div class="form-group">
                            <div class="col-md-6 col-md-offset-4">{!! Recaptcha::render() !!}
                             @if ($errors->has('g-recaptcha-response'))
                                 <span class="help-block">
                                     <strong>{{ $errors->first('g-recaptcha-response') }}</strong>
                                 </span>
                             @endif
                            </div>
                        </div>