Form should execute when captcha is there

<form id="easy" name="contact" method="post" action="submit.php" onSubmit="return checkform()">

I think that this is a Javascript question. so posting in the separate thread. whether captcha is chosen or not, the submit.php executes. what I want is unless and until the google captcha is filled the submit.php should not execute.

The captcha code is in the end of form like this →

<div class="g-recaptcha" data-sitekey="API_KEY"></div>
<span>
<?php if(isset($recaptchaErrors[0]))
echo $recaptchaErrors[0]; ?>
</span>

The form.js has this code

I tried something:

div class="g-recaptcha" data-sitekey="yyyyyyyyyy__xxxxxxxx"  data-callback="enableBtn"></div>    

		<button type='submit' class="button" id='send_message'>Send</button>
		<script type="text/javascript">
					 document.getElementById("send_message").disabled = true;

		 function enableBtn(){
		    document.getElementById("send_message").disabled = false;
   }
		</script>

But the button is not getting disabled initially when the captacha is notb ticked.

So just… define the button as disabled?

<button type='submit' class="button" id='send_message' disabled >Send</button>
1 Like

when disbaled I want to chnage the color to grey how to traget such CSS?

when Not disabled it should look like what it is looking now.

CSS has a selector for that. :disabled.

So…

button:disabled {
  background-color: grey;
}
1 Like

Tried not working.

https://codepen.io/EtoileLion/pen/ZMQNYN Works for me…you’d have to show me your code for better debugging response than that.

1 Like

can we target disabled and hover together also?

Yup. Pen updated.

1 Like

Mission accomplished.

1 Like

You taught me great things today. you are nice. Thanks.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.