Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NoCaptcha ReCaptcha/Bootstrapvalidator

Status
Not open for further replies.

Swi

Programmer
Feb 4, 2002
1,963
US
Is there a way to validate No Captcha ReCaptcha via BootstrapValidator?

I have some BootstrapValidator code that validates the form before it is submitted.

Code:
<script>
  $(document).ready(function() {
    $('#registered').bootstrapValidator({
        container: '#messages',
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        fields: {
            firstname: {
                validators: {
                    notEmpty: {
                        message: 'First Name is required and cannot be empty'
                    },
                    stringLength: {
                        max: 30,
                        message: 'First name cannot be longer than 30 characters'
                    }
                }
            },
            lastname: {
                validators: {
                    notEmpty: {
                        message: 'Last Name is required and cannot be empty'
                    },
                    stringLength: {
                        max: 30,
                        message: 'Last name cannot be longer than 30 characters'
                    }
                }
            },
            city: {
                validators: {
                    notEmpty: {
                        message: 'City is required and cannot be empty'
                    },
                    stringLength: {
                        max: 30,
                        message: 'City cannot be longer than 30 characters'
                    }
                }
            },
            state: {
                validators: {
                    notEmpty: {
                        message: 'State is required and cannot be empty'
                    }
                },
            },
            zip: {
                validators: {
                    zipCode: {
                        country: 'US',
                        message: 'The zip is not valid US postal code'
                    },
                    notEmpty: {
                        message: 'Zip is required and cannot be empty'
                    },
                    stringLength: {
                        max: 10,
                        message: 'Zip cannot be longer than 10 characters'
                    }
                },
            },
            mobile: {
                validators: {
                    phone: {
                        country: 'US',
                        message: 'Mobile Phone is not valid US phone number'
                    },
                    notEmpty: {
                        message: 'Mobile Phone is required and cannot be empty'
                    },
                    stringLength: {
                        max: 12,
                        message: 'Mobile Phone cannot be longer than 12 characters'
                    }
                }
            },
            home: {
                validators: {
                    phone: {
                        country: 'US',
                        message: 'Home Phone is not valid US phone number'
                    },
                    stringLength: {
                        max: 12,
                        message: 'Home Phone cannot be longer than 12 characters'
                    }
                }
            },
            password: {
                validators: {
                    notEmpty: {
                        message: 'Password is required and cannot be empty'
                    },
                    stringLength: {
                        max: 8,
                        message: 'Password cannot be longer than 8 characters'
                    }
                }
            },
            confirmpassword: {
                validators: {
                    identical: {
                        field: 'password',
                        message: 'The password and the confirmation are not the same'
                    },
                    notEmpty: {
                        message: 'Confirm Password is required and cannot be empty'
                    },
                    stringLength: {
                        max: 8,
                        message: 'Confirm Password cannot be longer than 8 characters'
                    }
                }
            }
        }
    });

If all of the above validates it posts to the next page and this is where I perform the ReCaptcha lookup:

Code:
Dim recaptcha_secret
Dim objXML
recaptcha_secret = "XXXXXXXXXXXXXXXXXXXXXXXX"

Dim sendstring
sendstring = _
   "[URL unfurl="true"]https://www.google.com/recaptcha/api/siteverify?"[/URL] & _
   "secret=" & recaptcha_secret & _
   "&response=" & request.form("g-recaptcha-response")

Set objXML = Server.CreateObject("MSXML2.ServerXMLHTTP")
objXML.Open "GET", sendstring , false

objXML.Send()

if instr(objXML.responseText,"false") > 0 then
        response.redirect "/register.asp?badlogin=4"
end if

%>

Does anyone know if I can do this in BootstrapValidator instead of posting to another page?

Just so everyone knows I am using Classic ASP.

Any help is greatly appreciated.


Swi
 
Is this is possible to do this in BootStrapValidator how secure is is to do on the client side? I would assume it would be just fine but want to make sure.

Thanks.

Swi
 
Got this working somewhat in Classic ASP as well.

Code:
function validateform(){
var captcha_response = grecaptcha.getResponse();
if(captcha_response.length == 0)
{
    // Captcha is not Passed
    $("#rcaptcha").removeClass("glyphicon-ok");
    $("#rcaptcha").addClass("glyphicon-remove");
    $("#rcaptcha").css("color","#FF0004");
    $("#setValueButton").removeClass('disabled');
    $("#setValueButton").removeAttr('disabled');
    $('#rcaptchamsg').show();
    return false;
}
else
{
    // Captcha is Passed
    $("#rcaptcha").removeClass("glyphicon-remove");
    $("#rcaptcha").addClass("glyphicon-ok");
    $("#rcaptcha").css("color","#00A41E");
    return true;
}
};

This was just to check to see if it was checked.

I also verify in Classic ASP on the server side.

Thanks.

Swi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top