0

As part of data entry I am checking the validity of a date field and using the onchange event to trigger the check. As you will note it also compares start and end dates, but that's not the issue. The issue is that after a bad date is detected and the alert pops up as it should, but the focus does not return to the violating field. I don't understand why. Please let me know if you have an explanation and/or fix. thanks.

David

The php code looks like this:
[php
<input id="date-due" name="goal_due" onchange="compare_goaldates(this); type="text" value="<?php echo '$goaldeadline' ?>"/>
]

[javascript
function compare_goaldates(fld){
var sdate= document.getElementById.value;
var edate= document.getElementById.value;

var retval = compareDates(sdate, edate);

if (retval == 99){
alert('Invalid date!');
fld.focus();
return false;
}
/* more stuff below*/
]

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Davife
0

Try a time delay after the alert.

It didn't make any difference, independent of the delay.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.