Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function validate() {
- console.log('validate()');
- var x = Math.round(Math.random() * 10);
- var y = Math.round(Math.random() * 10);
- var answer = x+y;
- var text = "Are you a human check\nWhat is "+x+" + "+y+" equal?";
- var userAnswer = prompt(text,"");
- if (answer==userAnswer) {
- console.log("correct");
- return true;
- } else {
- console.log("not correct");
- var request = new XMLHttpRequest();
- request.open('GET', '/checkout_rejected', true);
- request.onload = function() {
- console.log("checkout_rejected status:"+this.status);
- };
- request.onerror = function() {
- // There was a connection error of some sort
- console.log("checkout_rejected onerror");
- };
- request.send();
- alert("In correct answer, please try again.");
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement