Category Archives: javascript

How can I validate google reCAPTCHA v2 using javascript/jQuery?

Questions: I have a simple contact form in aspx. I want to validate the reCaptcha (client-side) before submitting the form. Please help. Sample code: <%@ Page Language=”VB” AutoEventWireup=”false” CodeFile=”Default2.aspx.vb” Inherits=”Default2″ %> <!DOCTYPE html> <html xmlns=””> <head runat=”server”> <title>Test Form</title> <link rel=”stylesheet” href=”//”> <script src=”//”></script> <script src=”//”></script> <link rel=”stylesheet” href=”/resources/demos/style.css”> <script src=”” async defer></script> <script> $(“#cmdSubmit”).click(function… Read More »

Secure random numbers in javascript?

Questions: How do I generate cryptographically secure random numbers in javascript? Answers: You can for instance use mouse movement as seed for random numbers, read out time and mouse position whenever the onmousemove event happens, feed that data to a whitening function and you will have some first class random at hand. Though do make… Read More »

Resetting a setTimeout

Questions: I have the following: window.setTimeout(function() { window.location.href = ‘file.php’; }, 115000); How can I, via a .click function, reset the counter midway through the countdown? Answers: You can store a reference to that timeout, and then call clearTimeout on that reference. // in the example above, assign the result var timeoutHandle = window.setTimeout(…); //… Read More »

How can I use goto in Javascript?

Questions: I have some code that I absolutely must implement using goto. For example, I want to write a program like this: start: alert(“RINSE”); alert(“LATHER”); repeat: goto start Is there a way to do that in Javascript? Answers: Absolutely! There is a project called Summer of Goto that allows you use JavaScript at its fullest… Read More »

Adding Prototype to JavaScript Object Literal

Questions: STORE = { item : function() { } }; STORE.item.prototype.add = function() { alert(‘test 123′); }; STORE.item.add(); I have been trying to figure out what’s wrong with this quite a while. Why doesn’t this work? However, it works when I use the follow: STORE.item.prototype.add(); Answers: The prototype object is meant to be used on… Read More »

How to detect timeout on an AJAX (XmlHttpRequest) call in the browser?

Questions: I’m looking on the web, but documentation is hard to come by. We all know the basic AJAX call using the browser’s built-in XMLHttpRequest object (assume a modern browser here): var xmlHttp = new XMLHttpRequest(); // Assumes native object“GET”, “”, false); xmlHttp.send(“”); var statusCode = xmlHttp.status; // Process it, and I’d love to… Read More »

What's the difference between JavaScript and JScript?

Questions: I have always wondered what the heck is the difference between JScript and JavaScript. Answers: Just different names for what is really ECMAScript. John Resig has a good explanation. Here’s the full version breakdown: IE 6-7 support JScript 5 (which is equivalent to ECMAScript 3, JavaScript 1.5) IE 8 supports JScript 6 (which is… Read More »