logo
down
shadow

jQuery captcha match


jQuery captcha match

By : Riyaz
Date : November 19 2020, 03:59 PM
wish of those help Make the AJAX Call to the new file named validate_captcha.php.
The PHP Code in file to handle AJAX Call
code :
    <?php
    session_start();
    $task       = !empty($_POST['task']) ? $_POST['task'] : null;
    $response   = 'false';
    if ( $task == 'validateCaptha' ){
        $inputCaptcha       = !empty($_POST['inputCaptcha']) ? $_POST['inputCaptcha'] : null;
        $sessionCaptcha     = $_SESSION['random_number'];

        if ($inputCaptcha   == $sessionCaptcha){
            $response   = 'true';
        }else{
            $response   = 'false';
        }
        echo $response; 
        exit();
    }

?>
    $(document).ready(function() {
    $('img#captcha-refresh').click(function() {
        change_captcha();
        });

        function change_captcha(){
            document.getElementById('captcha').src="reCaptcha/get_captcha.php?rnd=" + Math.random();
        }

$('#captcha-code').on('change', function(){
    var inputCaptcha = $(this).val();
    $.ajax({
    url: 'reCaptcha/validate_captcha.php',
    type: 'POST',
    async: false,
    data: {'task':'validateCaptha', 'inputCaptcha':inputCaptcha},
    success: function(response){
        if (response=='true'){
            alert('Match');
        }else{
            alert('Not Match');
        }
    }

});
         });
});


Share : facebook icon twitter icon
Validating Captcha after server round-trip and subsequent re-generation of captcha

Validating Captcha after server round-trip and subsequent re-generation of captcha


By : user1733772
Date : March 29 2020, 07:55 AM
I hope this helps you . So, I decided to implement reCaptcha. And I've customized my view likewise:
code :
<div id="recaptcha_image"></div>&nbsp;
     <a href="#" onclick="Recaptcha.reload();">
            generate a new image
     </a><br />
<input type="text" name="recaptcha_response_field" 
           id="recaptcha_response_field" />
           &nbsp;<%= Html.ValidationMessage("attemptCaptcha")%>
<script type="text/javascript" 
     src="http://api.recaptcha.net/challenge?k=[my public key]"></script>
<style type="text/css">
    #recaptcha_widget_div {display:none;}
</style>
[CaptchaValidator]
[AcceptVerbs(HttpVerbs.Post)]
public ViewResult SubmitEssay(Essay essay, bool acceptsTerms, bool captchaValid)
{
    if (!acceptsTerms)
        ModelState.AddModelError("acceptsTerms", 
                     "You must accept the terms and conditions.");
    else
    {
       try
       {
            // save/validate the essay
            var errors = essay.GetRuleViolations(captchaValid);
            if (errors.Count > 0)
                throw new RuleException(errors);

        }
        catch (RuleException ex)
        {
            ex.CopyToModelState(ModelState, "essay");
        }
    }
    return ModelState.IsValid ? View("Completed", essay) : View();
}

public NameValueCollection GetRuleViolations(bool captchaValid)
{
    var errors = new NameValueCollection();
    if (!captchaValid)
        errors.Add("attemptCaptcha", 
             "Please enter the correct verification text before submitting.");
    // continue with other fields....
}
public class CaptchaValidatorAttribute : ActionFilterAttribute
{
    private const string CHALLENGE_FIELD_KEY = "recaptcha_challenge_field";
    private const string RESPONSE_FIELD_KEY = "recaptcha_response_field";

    public override void OnActionExecuting(ActionExecutingContext filterContext)
    {
        var captchaChallengeValue = 
             filterContext.HttpContext.Request.Form[CHALLENGE_FIELD_KEY];
        var captchaResponseValue = 
             filterContext.HttpContext.Request.Form[RESPONSE_FIELD_KEY];
        var captchaValidtor = new Recaptcha.RecaptchaValidator
          {
              PrivateKey = "[my private key]",
              RemoteIP = filterContext.HttpContext.Request.UserHostAddress,
              Challenge = captchaChallengeValue,
              Response = captchaResponseValue
          };

        var recaptchaResponse = captchaValidtor.Validate();

    // this will push the result value into a parameter in our Action
        filterContext.ActionParameters["captchaValid"] = recaptchaResponse.IsValid;

        base.OnActionExecuting(filterContext);
    }
}
public static class Captcha
{
    public static string GenerateCaptcha( this HtmlHelper helper )
    {  
    var captchaControl = new Recaptcha.RecaptchaControl
        {
            ID = "recaptcha",
            Theme = "clean",
            PublicKey = "[my public key]",
            PrivateKey = "[ my private key ]"
        };
    var htmlWriter = new HtmlTextWriter( new StringWriter() );
        captchaControl.RenderControl(htmlWriter);
    return htmlWriter.InnerWriter.ToString();
    }
}
html contact form with captcha submit to jquery&php .AJAX captcha validation request without form submit

html contact form with captcha submit to jquery&php .AJAX captcha validation request without form submit


By : BLELEI
Date : March 29 2020, 07:55 AM
it helps some times I am new to jquery php..please help me on this issue to resolve.
code :
<form id="RegisterUserForm" name="RegisterUserForm" action="" onsubmit="return submitform();" method="post">
    <fieldset style="border: 0;">
        <table width="100%">
            <tr>
                <td width="150">
                    <div class="celebrationContent">
                        Name:</div>
                </td>
                <td class="style1">
                    <input id="Name" type="text" name="Name" style="border-style: none; background-color: #fffcc4;
                        width: 275px;" />
                </td>
            </tr>
            <tr>
                <td>
                    <div class="celebrationContent">
                        E-mail id:</div>
                </td>
                <td class="style1">
                    <input id="email" type="text" name="email" style="border-style: none; background-color: #fffcc4;
                        width: 274px;" />
                </td>
            </tr>
            <tr>
                <td class="celebrationContent">
                    Phone Number:
                </td>
                <td class="style1">
                    <input id="phonenumber" type="text" name="phonenumber" style="border-style: none;
                        background-color: #fffcc4; width: 274px;" />
                </td>
            </tr>
            <tr>
                <td class="celebrationContent">
                    Your Celebration:
                </td>
                <td class="style1">
                    <input id="yourCelebration" type="text" name="yourCelebration" style="border-style: none;
                        background-color: #fffcc4; width: 274px; height: 33px;" />
                </td>
            </tr>
            <tr>
                <td class="celebrationContent">
                    When is it:
                </td>
                <td class="style1">
                    <input type="text" id="Whenisit" name="Whenisit" style="border-style: none; background-color: #fffcc4;
                        width: 272px;" />
                </td>
            </tr>
            <tr>
                <td class="celebrationContent">
                    Enquiry:
                </td>
                <td class="style1">
                    <input type="text" id="Enquiry" name="Enquiry" style="border-style: none; background-color: #fffcc4;
                        width: 272px; height: 70px;" />
                </td>
            </tr>
            <tr>
                <td colspan="2" align="left" class="celebrationContent">
                    Verification Code
                </td>
            </tr>
            <tr>
                <td align="left" colspan="2">
                    <table width="100%">
                        <tr>
                            <td width="32%">
                                <img src="captcha.php" alt="celebration captcha" />
                            </td>
                            <td>
                                <input type="text" id="verificationcode" name="verificationcode" style="border-style: none;
                                    background-color: #fffcc4" />
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td colspan="2" align="center">
                    <input type="submit" id="form_submit" />
                </td>
            </tr>
        </table>
    </fieldset>
    </form>
    <script type="text/javascript">
    function submitform() {

        if (validateCaptach()) {
            var sData = $("#RegisterUserForm").serialize();
            $.ajax({
                type: "POST",
                url: "thankyou.php",
                data: sData,
                success: function (data) {
                    if (data == "SUCCESS") {
                        alert("sucess..");
                    } else {
                        alert("some error please type again...");
                    }
                }
            });
        }

        return false;
    }

    function validateCaptach() {
        var captchaval = $("#verificationcode").val();

        $.ajax({
            type: "POST",
            url: "captchacheck.php",
            data: {
                verificationcode: captchaval
            },
            success: function (data) {
                if (data == "SUCCESS") {
                    alert("captchacheck sucess..");
                    return true;
                } else {
                    alert("The security code you typed was wrong. Please try again.");
                    return false;
                }
            }
        });
        return false;

    }

    </script>
Si Captcha Version 2.7.7.1 - Wordpress - Unreadable CAPTCHA token file error

Si Captcha Version 2.7.7.1 - Wordpress - Unreadable CAPTCHA token file error


By : manoj199
Date : March 29 2020, 07:55 AM
I wish did fix the issue. Looking online, everywhere says to add a temp folder at /wp-content/plugins/si-captcha-for-wordpress/captcha folder path and give it permissions 777. This seems to no longer be the case. It seems that you must now change the cache folder's permissions to 777 within this same folder path for the latest version. Just putting this here so others know.
Laravel4 Validator, Captcha, & Session unable to match

Laravel4 Validator, Captcha, & Session unable to match


By : sthairdthai
Date : March 29 2020, 07:55 AM
seems to work fine According to Laravel's docs, same refers to another input.
I'd recommend using a custom validation rule to compare the session and the input.
How to integrate BotBoot captcha and disable submit button until captcha is correct?

How to integrate BotBoot captcha and disable submit button until captcha is correct?


By : Ludovic Mercier
Date : March 29 2020, 07:55 AM
hop of those help? I have modified a few parts of your code to get this working. A working JSFiddle can be found at http://jsfiddle.net/QVXS3/1/.
The first part of the code I modified was the HTML (mostly for JSFiddle Purposes).
code :
<div id="botboot"></div>
<input type="submit" id="form_submit" class="btn btn-lg btn-default cta" name="Submit" disabled>
<script>DrawBotBoot()</script><br>
function DrawBotBoot() {
    var div = document.getElementById('botboot');
    var input = document.createElement('input');
    input.name = 'botboot';
    input.id = 'BotBootInput';
    input.type = 'number';
    input.class = 'input_field';
    input.setAttribute('maxlength','2');
    input.setAttribute('size','2');
    input.setAttribute('required','required');
    input.addEventListener('keyup',ValidBotBoot,false);
    div.innerHTML += "<label for='botboot' class='contact_label'>What is "+ a + " + " + b +"?</label>";
    div.appendChild(input);
}    
function ValidBotBoot(e) {
    var submit = document.getElementById('form_submit');
    var d = e.target.value;
    if (d == c) {
        submit.removeAttribute('disabled');
        return true;   
    }else{
        submit.setAttribute('disabled','disabled');
    }
    return false;  
}
Related Posts Related Posts :
  • React | Can´t load Images > Module not found
  • Dynamically creating buttons in DOJO
  • 404 Not Found in AJAX post call
  • How do I find out, using javascript, what software opened and running my application?
  • Javascript to check the status of wireless connection
  • StarDict support for JavaScript and a Firefox OS App
  • Phonegap event Resume
  • call javascript function on ENTER key press?
  • When is the best time to remove no-js classes from the html tag
  • Recommended email sending languages
  • setInterval not working properly with chrome
  • Does IE create new scope for each script tag?
  • Uncaught SyntaxError: Unexpected token < Underscore and parse issues
  • How to pass captured URL to Email Body in HTML
  • How to structure default nested resources?
  • Store all the keys of a JSON object in a variable
  • Need an efficient way to group the Array of object in javascript
  • a sensible approach to highcharts x-axis labels
  • IDE autocompletion for javascript AMD loading style
  • Bootstrap menu disappears after first click setting the ul style to none
  • split ajax json response errors in each field
  • how to add javascript in head in cmsms
  • REGEX: Finding the correct occurrence order of some given special characters in a string
  • How do you preserve a JavaScript date's time zone from browser to server, and back?
  • Return binary result from phantomjs webserver
  • must be listed in the web_accessible_resources manifest key in order to be loaded by pages outside the extension.
  • Replacing a substring of an element's text with another string
  • How do I filter marks greater than or equal to 90 in this array?
  • Modify the text of my radio input button?
  • Clicking on status bar does not scroll to top of app (Trigger.io)
  • Mocha JS: How to highlight specific assertion failure?
  • $.getJSON jquery parsing to HTML
  • Find items of a certain class (a) that are also in other classes (b,c,d)
  • Setting different images for D3 force-directed layout nodes
  • Integrating Dropzone.js with angular
  • Control sprite animation speed
  • Can only one error / success function be assigned for AngularJS $http promises?
  • Working with math in javascript
  • Django variable isnt recognized by javascript
  • $.when does not work with $.scrollTo plugin
  • How to read local xml file using $.ajax?
  • Manifest is not Valid JSON. What is wrong?
  • AngularJS re-initialise JS after statechange
  • WebRupee is not working
  • How can I make the jQuery MultiSelect widget read-only?
  • How to associate javascript code with dom elements?
  • How to remove track from MediaStream and "stop" webcam?
  • clearvalidators not working in angular 6 form control
  • Remove Count Attribute in json data
  • queue up function callbacks
  • How to stop all Soundcloud streams in once?
  • Sliding div onclick left/right
  • RequireJS JQuery shim doesnt work with VS2013
  • What is the Meteor concurrency model?
  • Events on children of contenteditable element
  • Simple jquery not working to print the input value
  • Javascript templating language in reverse
  • Making Pagination in Javascript Scalable (for large # of db results)
  • Performance of Stateless Authentication in SPA and SSO (Single Sign On)
  • Assigning a value for view asynchronously
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org