homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

calling external javascript with an onBlur event

 9:43 pm on Nov 13, 2003 (gmt 0)

I am trying to call an external javascript file when an onBlur event is triggered.

In the header

<script language="JavaScript" src="validateEntry.js"></script>

In the body

<input type=text name=DateEntered value="<%= sDateEntered %>" size=15 onBlur="isDate(this);">

in the javascript file validateEntry.js

function isDate(field) {
var validValue = /^\b(1[0-2]¦0?[1-9])\/(0?[1-9]¦[12][0-9]¦3[01])\/((19¦20)\d{2})(\s)(0?[0-9]¦1[0-9]¦2[0-4]):[012345][0-9]$/;
if (field.value!= "" &&!validValue.test(field.value)) {
status = field.name + ": Value is: " + field.value + " Length is: " + field.value.length;
//alert(field.name + ": This field requires m/dd/yyyy hh:mm format")
return false;
return true;

All I get is an object expected error when the onBlur event triggers.

Any help would be appreciated.




 3:44 pm on Nov 17, 2003 (gmt 0)

Since you haven't gotten a response yet, I will offer a wild guess. I think the function is having trouble with your SSI. Maybe (BIG MAYBE) this will work.

<script language="JavaScript" type="text/javascript">
var myDate = <%= sDateEntered %>;
document.write('<input type="text" name="DateEntered" value="'
+ myDate +
'" size="15" onBlur="isDate(this);">');


 4:08 pm on Nov 17, 2003 (gmt 0)


Thanks for the input, as it turns out the reason I was getting the error message was because the browers cache needed to be flushed. After clearing the cache the error went away and the code ran as expected.




 4:44 pm on Nov 17, 2003 (gmt 0)

I would not have thought of that, but I will from now on.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved