/*
	Used for formatting Dates to 01/23/1234 
	Designed by Rob Reynolds (BCS) Copyright 2004 by KDOT.
	
	TO USE: Include below in your textbox or in a span element surrounding your asp:TextBox.	
	onkeyup="formatDate('fieldID');"
*/

var lastDateLength;

function formatDate(field) {
	strDateField = document.getElementById(field).value;
	strDate = "";

	if (strDateField.length > lastDateLength) {
		for (x = 0; x < strDateField.length; x++) {
			strDateInt = strDateField.charCodeAt(x);
			//alert(strDateField.charCodeAt(x));
			if ((strDateInt > 46) && (strDateInt < 58)) {
				strDate += strDateField.substr(x, 1);
			}
		}
		if ((strDate.length > 2) && (strDate.substr(2, 1) != "/")) {
			strDate = strDate.substr(0, 2) + "/" + strDate.substr(2, (strDate.length - 2));
		}
		if ((strDate.length > 5) && (strDate.substr(5, 1) != "/")) {
			strDate = strDate.substr(0, 5) + "/" + strDate.substr(5, (strDate.length - 5));
		}
	} else {
		strDate = strDateField;
	}

	if (strDate.length > 10) {
	strDate = strDate.substr(0, 10);
	}
	document.getElementById(field).value = strDate;
	lastDateLength = strDate.length;
}	