albertcht / invisible-recaptcha

An invisible reCAPTCHA package for Laravel, Lumen, CI or native PHP.
MIT License
601 stars 162 forks source link

form dosen't submit in laravel #134

Closed mrmmg closed 3 years ago

mrmmg commented 3 years ago

Hi My Form Does not submit in laravel and in Console this error appears: Uncaught (in promise) null.

If I remove @captcha('en') from blade template the problem solved and form submit successfully.

Do you have any solution?

zhanang19 commented 3 years ago

Can you provide more detail? I think it can be a simple script about that. Cause I can't replicate the issue in my side.

mrmmg commented 3 years ago

@zhanang19 detail like what? can you expain a liitle bit more?

mrmmg commented 3 years ago

@zhanang19

My form (blade template) is:

                <form action="{{route('save-comment')}}" method="post" id="commentform" class="comment-form">
                    <div class="form-group">
                        <label class="form-label" for="author">name</label>
                        <div class="form-item-wrap">
                            <input class="form-item" id="author" name="author" type="text" value="" size="30" maxlength="245" aria-required="true" required>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="form-label" for="email">email</label>
                        <div class="form-item-wrap">
                            <input class="form-item" id="email" name="email" type="email" dir="ltr" value="" size="30" maxlength="100" aria-describedby="email-notes" aria-required="true" required>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="form-label" for="comment2">your commenet</label>
                        <div class="form-item-wrap">
                            <textarea class="form-item" id="comment" name="text" cols="45" rows="8" maxlength="65525" aria-required="true" required></textarea>
                        </div>
                    </div>

                    @captcha('en')
                    @csrf
                    <div class="form-submit">
                        <input class="btn btn-primary btn-lg" name="submit" type="submit" value="submit">
                    </div>
                </form>

And that's it. no more information!

mrmmg commented 3 years ago

@zhanang19 sorry for my comments the debug in console return this error:

image

JWardee commented 3 years ago

Just had this exact issue and it turns out it was because my localhost domain wasn't an allowed domain. Make sure you can see the badge by setting INVISIBLE_RECAPTCHA_BADGEHIDE=true in your .env. Once I added my domain it works fine - hope this helps!