Nirali Joshi Nirali Joshi - 1 year ago 303
Javascript Question

Error: ReCAPTCHA placeholder element must be empty

I am using recaptcha with my laravel application.

I just want to check recaptcha's response on form submit using jquery and stop user by alert that pleade validate captcha.

but , I could not stop form submission even if captcha is not filled.

here is my code.

$('#payuForm').on('submit', function (e) {

var response = grecaptcha.getResponse();

if(response.length == 0 || response == '' || response ===false ) {
alert('Please validate captcha.');

<div class="captcha">
{{ View::make('recaptcha::display') }}

I am getting this error in browser console , and form gets submit.

Error: ReCAPTCHA placeholder element must be empty

Answer Source

You are loading the google recaptcha library twice.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download