I am now trying this:
Code:
function isValidDate(dateString) {
if(!/^([0-9]{2})\/([0-9]{2})\/([0-9]{4})$/.test(dateString))
return false;
var parts = dateString.split("/");
var day = +parts[1];
var month = +parts[0]-1; var year = +parts[2];
if(year < 1000 || year > 3000)
return false;
var dt = new Date(year, month, day);
if (dt.getDate() !== day || dt.getMonth() !== month || dt.getFullYear() !== year) return false;
return true; }
Followed by this:
Code:
function validateForm( frm )
{
var oops = "";
var apptype = getRBValue( frm.elements["MoveType."] );
if ( apptype == null )
oops += "You must check Temporary or Permanent.\n";
var apptype = getRBValue( frm.elements["ResSummer."] );
if ( apptype == null )
oops += "You must check Yes or No for residential summer student.\n";
if ( trim( frm.elements["FirstName."] ).length < 2 )
oops += "You must enter your First name.\n";
if ( trim( frm.elements["LastName."] ).length < 2 )
oops += "You must enter your Last name.\n";
if ( ! emailCheck( frm.elements["Email."] ) )
oops += "That does not appear to be a valid Email Address.\n";
if (trim( frm.elements["Box."] ).length < 1 || trim( frm.elements["Box."] ).length > 4)
oops += "You must enter a Box# (Max 4 digits).\n";
if ( ! isValidDate( frm.elements["EffectiveDate."] ) )
oops += "You must enter your Effective Date of Move in the proper format (MM/DD/YYYY).\n";
if ( trim( frm.elements["StreetAddress."] ).length < 5 )
oops += "You must enter your Street Address.\n";
if ( trim( frm.elements["City."] ).length < 4 )
oops += "You must enter your City.\n";
if ( trim( frm.elements["State."] ).length < 1 )
oops += "You must enter your State.\n";
if ( ! zipCheck( frm.elements["Zip."] ) )
oops += "You must enter a 5 digit Zip Code.\n";
// additional building and room are not validated, but they are are trimmed and upper cased
trim(frm.Apt);
var inps = frm.elements;
var chkbx = false;
for ( var i = 0; i < inps.length; ++i )
{
var inp = inps[i];
if ( inp.name.indexOf("ChkBx") > 0 && inp.value != "" && inp.checked )
{
var chkbx = true;
break;
}
}
if ( oops == "" ) return true;
alert("ERROR(S):\n" + oops);
return false;
}
After the rest of my functions....still doesn't work with a legit date...