Archive for the ‘Javascript’ Category

How to create a masked textbox using JavaScript

Wednesday, July 8th, 2009

This article demonstrates how to implement a masked input box or masked textbox using JavaScript. For example, let's imagine you have a simple HTML form and want to restrict the user to enter on numbers in a Telephone number field. The following code will demonstrate how to to capture the ...

Random number generator for JavaScript

Tuesday, July 7th, 2009

Need to know how to generate a random number in JavaScript? The following code will do the job. There are a lot of articles on the internet explaining how to generate a random number between 0 and 10 (for example), but not so many explaining how to generate a random ...

Storing data in HTML elements using attributes

Sunday, June 1st, 2008

This article aims to illustrate 2 useful concepts. Firstly, to illustrate how to use the getAttribute and setAttribute methods of the DOM (Document Object Model) to "store" or "attach" data to DOM elements. Secondly, to show how this can be used as a way to "pass" data to Javascript event ...

Prevent session timeout in your ASP.NET AJAX application

Thursday, May 29th, 2008

Here's an interesting problem I encountered recently. With a traditional ASP.NET web application each time a user requests a page from the server, the server will reset the user's session timeout counter and hence prevent the user's session from timing out. However, suppose I have an AJAX.NET application which is ...

Javascript, the DOM, and memory leaks

Thursday, May 29th, 2008

Having recently starting implementing more Ajax into my web applications I discovered a new issue today that I've never considered or encountered before in my 10+ years of using Javascript; namely memory management and memory leaks. This is actually an issue involving both Javascript and the DOM.