Dealing with IE is a constant struggle for me. My goal is to implement validation that runs from a button within a tab to prevent users from skipping tabs without filling in data, which could potentially cause issues with my database queries.
$("[id$='tab_TabContainer1_TabPanel2']").click(function (e) {
var container = $find('TabContainer1');
if (event.preventDefault) {
event.preventDefault(); //works for anything with preventDefault (e.g., not called from html onclick, etc.)
}
else {
event.returnValue = false; //specifically for IE - on global event 'event'
}
$("[id$='Button1']").click(); //trigger the button1 click event (which initiates custom validation)
if (Page_IsValid) {
container.set_activeTabIndex(1); //move to the next tab
}
else {
container.set_activeTabIndex(0); //stay on the current tab
}
return false;
});
It seems straightforward, and it works fine in firefox and chrome, but IE8 is giving me trouble. In IE8, it simply advances to the next tab after validation, regardless of any checks. Even if I include a return false; immediately, IE8 just moves to the next tab. It's like dealing with a persistent honey badger. Any suggestions?