// <INPUT TYPE="TEXT" NAME="strBirthday" VALUE="<%=RS("Birthday")%>" MAXLENGTH="10" SIZE="10" onBlur="BDayCHK(this.value, this);">

// VARIABLE DECLARATIONS

var digits = "0123456789";
var BithdateDelimiters = "-";
var digitsInBirthdate = 8;

// Removes all characters which appear in string bag from string s.

function stripCharsInBag (s, bag)

{   var i;
    var returnString = "";

    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }

    return returnString;
}



// Removes all characters which do NOT appear in string bag 
// from string s.
function stripCharsNotInBag (s, bag)

{   var i;
    var returnString = "";

    // Search through string's characters one by one.
    // If character is in bag, append to returnString.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) != -1) returnString += c;
    }

    return returnString;
}

function reformat (s)
{   var arg;
    var sPos = 0;
    var resultString = "";

    for (var i = 1; i < reformat.arguments.length; i++) {
       arg = reformat.arguments[i];
       if (i % 2 == 1) resultString += arg;
       else {
           resultString += s.substring(sPos, sPos + arg);
           sPos += arg;
       }
    }
    return resultString;
}

function BDayCHK(number, numberfield)
{
if 	(number.length != 0)
	{
	number = stripCharsNotInBag(number, digits)
										
	if (number.length < 8 || number.length > 8) 
		{
		alert('please enter a valid birthday including...\n\n     --- a 2 number month\n     --- a 2 number day\n     --- and a 4 number year. \n\n     --- example:  03-05-1975')
		numberfield	.focus();
		}
	else
		{
		number = reformat (number, "", 2, "-", 2, "-", 4)
		numberfield.value = number  //document.form.field.value = number
		}
	}
}
