December 19, 2006

Simple ZIP/Postal code validation

Simple javascript function to validate 5 digit US ZIP Code and Canadian Postal code format.

US ZIP Codes in the format "NNNNN".
Canadian Postal Codes in the format "LNL NLN".

Returns true if valid, false if not. This example needs the id of the ZIP/Postal Code field to be named "zipcode".

function validZip() {
   var zip = document.getElementById('zipcode').value;
   var zipRegExp = /(^\d{5}$)|(^\D{1}\d{1}\D{1}\s\d{1}\D{1}\d{1}$)/;
   return zipRegExp.test(zip);
}

October 3, 2006

Filtering directories from cfdirectory in ColdFusion

The examples tell you just to loop over the query returned by cfdirectory but it is much faster to do a subquery and use it instead.

<cfdirectory action="list" directory="C:\" name="treebase" recurse="yes">

<cfquery dbtype="query" name="treebaseFiltered">
SELECT Name, Directory
FROM treebase
WHERE Type = 'Dir'
</cfquery>

September 26, 2006

Does anyone check content before posting it anymore?

Here we have a large company website, a tutorial on embedding swf files into browsers, and a guy with a t-shirt with two unicorns getting it on. Though not completely unrelated since the page is about embedding objects.

Adobe - Developer Center : JavaScript Flash Player Detection and Embedding with SWFObject

September 20, 2006

iTunes 7.0.0.70 and Remote Desktop

iTunes 7 crashes with an error "0x666d743f" when using Remote Desktop on Windows XP.

The easy workaround I have found is to disable the sounds in the Remote Desktop settings before connecting. Apparently there are some other reported driver issues with this version of iTunes as well.

August 15, 2006

Speedtest.net

Check this out. It's a slick interface for checking your internet connetion speeds.



Speedtest.net