<?php
if(isset($_REQUEST['Submit'])) {
echo "Submitted".'<br/>';
}
?>
<!doctype html>
<html>
<head>
<title> Recaptcha validation using jquery ajax </title>
</head>
<body>
<form id="add-conference" method="post">
<table>
<div class="container">
<div class="form-group">
<div class="row">
<div class="col">
<input name="txt_password" id="txt_password" placeholder="Password" class="form-control f-4 m-wrap" value="" type="password">
</div>
</div>
</div>
</div>
<input type="hidden" class="hiddenRecaptcha required" name="hiddenRecaptcha" id="hiddenRecaptcha">
<div class="g-recaptcha" data-sitekey="6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI"></div>
<input type="submit" value="Submit" id="submitAddForm" name="Submit">
</table>
</form>
</body>
</html>
<script type="text/javascript">
$(document).on('click', '#submitAddForm', function (e) {
$("#add-conference").validate({
ignore: ".ignore",
rules: {
txt_password: {required: true, minlength: 6},
"hiddenRecaptcha": {
required: function() {
if(grecaptcha.getResponse() == '') {
return true;
} else {
return false;
}
}
}
},
messages:
{
txt_password: { required: "Please Enter Password", minlength: "Please choose a password with min length 6"},
"hiddenRecaptcha": { required: "Captcha Required" }
},
});
});
</script>