Validating Bank Routing Numbers In JavaScript

Example code at

I have a test script at that I recently updated. I am having a hard time finding good documentation on it but ABA routing numbers that start with the number 5 are not valid. Routing numbers that start with 5 are internal bank routing numbers and are not valid for ACH transfers. Customers will often not realize that the routing number on their checks and the routing numbers on their bank deposit slips are different.

Here are the checks that I am doing in my JavaScript example:

  • routing number is a number
  • is 9 numbers in length
  • does not start with the number 5
  • checksum of routing number validates

For more information on the checksum for ABA routing numbers, check out wikipedia.

References for routing numbers starting with 5 being internal routing numbers:!topic/checkout-merchant/9XeAX4LAlqY

Test Your JavaScript As You Code

If you are writing JavaScript, you should be testing and linting your code often to catch common mistakes. I enjoy using Sublime Text so I have installed Sublime-JSHint, a Submlime Text 2 plugin that checks my JavaScript code for nasty errors and other coding goodies.

Sublime JSHint in action

It’s super easy to setup so what are you waiting for?!

If you don’t use Sublime Text, find a jshint plugin for your editor over at

JavaScript Test For Valid US Phone Number


Example and script at

In building an app, I needed to check for a valid phone number based on user input. After reading and learning more about US phone numbers than I cared about, I was able to come up with a basic way to check for a valid US phone number using JavaScript. It only marks a phone number as invalid if it is a phone number that is not a possible phone number or a special phone number that customers will not have (800 numbers, etc.).

I built a US phone number validation test page that will test phone numbers you input and give the reason why it fails if it doesn’t pass validation. You can check it out at

Resources I ended up using in my research or the formulation of the algorithm:


Photo by Paul L

IE8 & IE7 JavaScript Date NaN From String Error

When trying to create a JavaScript Date object from a string I was getting an NaN error in IE7 and IE8. My JavaScript worked in all the other browsers I was testing in. I was writing the script to figure out future dates based on the date the user selected. Issue is that IE7 and 8 don’t handle strings as well as real browsers. I was able to fix the error by using date.setFullYear instead of expecting the browser to handle it. Found a great function in to handle this.


function parseISO8601(dateStringInRange) {
	var isoExp = /^\s*(\d{4})-(\d\d)-(\d\d)\s*$/,
		date = new Date(NaN), month,
		parts = isoExp.exec(dateStringInRange);

	if(parts) {
		month = +parts[2];
		date.setFullYear(parts[1], month - 1, parts[3]);
		if(month != date.getMonth() + 1) {
	return date;

You can check out my reduced test case.