hey there, I'm struggling with my captcha code. The issue is that it still accepts wrong captchas when entered in the input box. Can someone guide me on how to validate the wrong captcha entry?
Here's my form code:
<p class="Captcha" style="margin-top:5%; width: 100%;">
<div style="margin:0 0 0 1%">
<label class="captchalabel" style="width:38%; float: left;"><span style="margin:0 0 0 9%">Enter the text </span> <span style="color:red">*</span>:</label>
<input style=" float: left;" type="text" name="defaultReal" required> </div>
<div style="width: 20%; float: right;" id="defaultReal">
</div>
</p>
Now, let's dive into the JavaScript part:
var x=document.forms["custRegistration"]["defaultReal"].value;
if (x==null || x=="")
{
alert("Please enter captcha code");
return false;
}
Lastly, let's take a look at the Js code:
(function($) { // No $ conflict
/* Real person manager. */
function RealPerson() {
this._defaults = {
length: 6, // Number of characters
includeNumbers: false,
regenerate: '<div style="margin: -18% 1% 0 80%;"><img src="images/captcha.png"/></div>',
hashName: '{n}Hash'
};
}
var CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
var DOTS = [
// omitted for brevity
];
$.extend(RealPerson.prototype, {
markerClassName: 'hasRealPerson',
propertyName: 'realperson',
setDefaults: function(options) {
$.extend(this._defaults, options || {});
return this;
},
_attachPlugin: function(target, options) {
// implementation removed for conciseness
},
_optionPlugin: function(target, options, value) {
// implementation removed for concisenness
},
// other methods removed for brevity
});
// List of commands that don't permit chaining
var getters = [''];
// Determine whether a command is a getter and doesn't permit chaining
function isNotChained(command, otherArgs) {
// implementation removed for conciseness
}
// jQuery plugin definition
$.fn.realperson = function(options) {
// implementation removed for conciseness
};
var plugin = $.realperson = new RealPerson();
$(document).on('click', 'div.' + plugin.propertyName + '-challenge', function() {
if (!$(this).hasClass(plugin.propertyName + '-disabled')) {
$(this).nextAll('.' + plugin.markerClassName).realperson('option', {});
}
});
})(jQuery);