onBlur event not calling javascript function

20 pts.
Tags:
JavaScript
first textbox works with script as it should but uses a submit button. Second textbox what I am trying to get to work and use script as you leave the textbox. I am using onBlur but not working. See code below. Validating date input - enter incorrect date so you can see error notification. <HTML> <HEAD> <TITLE>Life Connection Program Survey</TITLE> <SCRIPT LANGUAGE="JavaScript"> function isValidDate(dateStr) { // Checks for the following valid date formats: // MM/DD/YY MM/DD/YYYY MM-DD-YY MM-DD-YYYY // Also separates date into month, day, and year variables var datePat = /^(d{1,2})(/|-)(d{1,2})2(d{4})$/; var matchArray = dateStr.match(datePat); // is the format ok? if (matchArray == null) { alert("Date is not in a valid format.") return false; } month = matchArray[1]; // parse date into variables day = matchArray[3]; year = matchArray[4]; if (month < 1 || month > 12) { // check month range alert("Month must be between 1 and 12."); return false; } if (day < 1 || day > 31) { alert("Day must be between 1 and 31."); return false; } if ((month==4 || month==6 || month==9 || month==11) && day==31) { alert("Month "+month+" doesn't have 31 days!") return false; } if (month == 2) { // check for february 29th var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)); if (day>29 || (day==29 && !isleap)) { alert("February " + year + " doesn't have " + day + " days!"); return false; } } return true; // date is valid } // End --> </script> </HEAD> <BODY background="lgrey011.jpg" onLoad="do_on_load()" Name="CONT"> <center> <form onSubmit="return isValidDate(this.date.value);"> Program End Date: <input type=text name=date size=10 maxlength=10> (in MM/DD/YYYY format) <input type=submit value="Submit Date"> </form> </center> <center> <form name=LCPSurvey method=get action=LCPSurvey.php> Program End Date: <input type=text name=date size=10 maxlength=10 onblur="isValidDate()"> (in MM/DD/YYYY format) </form> </center> </BODY> </HTML>

Answer Wiki

Thanks. We'll let you know when a new response is added.

you are right, I needed to drop the date out of (this.date.value)
got it working. thanks for your help

Have you tried onblur=”isValidDate(this.value)”>

Earl

http://www.duckin4printing.com/

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following