Кнопка отправки отключена, пока не будет решена Recaptcha. Но теперь форма не подтверждается, пока не будет решена RecapJquery

Программирование на jquery
Ответить
Anonymous
 Кнопка отправки отключена, пока не будет решена Recaptcha. Но теперь форма не подтверждается, пока не будет решена Recap

Сообщение Anonymous »

Кнопка отправки отключена до тех пор, пока не будет решена recaptcha. Но теперь форма не подтверждается до тех пор, пока не будет решена Recaptcha. Как мне настроить так, чтобы форма проверила до того, как решается Recaptcha, но не отправляется в форму?
>
< /code>
javascript < /h3>
function enableBtn() {
var response = grecaptcha.getResponse();
var $result = $('#myParagraph');
if(response.length === 0) {
$result.text("reCaptcha not verified");
}
else {
$result.text("reCaptcha Verified");
document.getElementById("g-recaptcha-response").setAttribute('value', response);
document.getElementById("button1").disabled = false;
}
}

< /code>
это то, что я попробовал < /h2>
html < /h3>




Submit

< /code>
javascript < /h3>
function checkInputs() {
const input1 = document.getElementById('input1').value;
const input2 = document.getElementById('input2').value;
const input3 = document.getElementById('input3').value;
const submitBtn = document.getElementById('submitBtn');

if (input1.trim() !== '' || input2.trim() !== '' || input3.trim() !== '') {
submitBtn.disabled = false; // Enable the button
} else {
submitBtn.disabled = true; // Keep the button disabled
}
}

// Initial check when the page loads (in case inputs are pre-filled)
document.addEventListener('DOMContentLoaded', checkInputs);
< /code>
Это то, что я имею для проверки на стороне клиента < /p>
$(document).ready(function() {
$("#emailForm").validate({
rules: {
contributor: {
required: true
},
email: {
required: true,
email: true
},
password: {
required: true,
minlength: 3
},
password_confirm: {
required: true,
equalTo: "#password"
}
},
messages: {
contributor: "Please enter your name",
email: {
required: "Please enter your email address",
email: "Please enter a valid email address"
},
password: {
required: "Please enter a password",
minlength: "Your password must be at least 3 characters long"
},
password_confirm: {
required: "Please confirm your password",
equalTo: "Passwords do not match"
}
}
});
});


Подробнее здесь: https://stackoverflow.com/questions/797 ... form-doesn
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Jquery»