$('#startDate').on('blur', function (event) {
if (!isDate(event.target.value)) { //isDate is a validation function, works fine
alert('Invalid Date');
event.target.value = '';
// setTimeout(function () { //the horror...the horror...
document.getElementById(event.target.id).focus();
// }, 1);
// event.preventDefault;
// event.stopImmediatePropagation;
// event.stopPropagation;
return false;
}
});
The browser (FF 9.0.1) apparently executes the focus() method, and then happily goes and focuses wherever the user had planned to go. I'm reduced to the frightful hack of pausing for a millisecond before executing the focus method so whatever thread is changing the focus can finish doing so, thereby allowing me to change it back.I have attempted using the change event as well, but that doesn't work either. Since it fires before blur, that's not surprising. I've tried all of the three commands I've commented out, with no luck.
Can someone give me a glimpse under the hood?
This post has been edited by BobRodes: 24 January 2012 - 03:52 PM

New Topic/Question
Reply


MultiQuote



|