0

IE is the bane of my existence. Basically, I want to run validation from a button within the tab if the user tries to skip tabs- to prevent them from not filling in data and potentially breaking 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;      //supposed to be IE specific - on global event 'event'
        }

        $("[id$='Button1']").click();   //perform the button1 click event (which calls custom validation)

        if (Page_IsValid) {
            container.set_activeTabIndex(1); //go ahead to next tab
        }
        else {
            container.set_activeTabIndex(0);    //stay here on current tab
        }
        return false;
    });

It should be that simple, and the above works in firefox/google chrome, but not IE8. IE8 simply just goes to the next tab after the validation, regardless of anything. Even if I return false; immediately, it just goes to the next tab. Honey Badger doesn't care, honey badger just goes to the next tab. Any ideas?

1 Answers1

0

Your problems is with the use of "event" rather than the e you've actually called the event. Change the event to an e as shown below and it should work fine! =]

$("[id$='tab_TabContainer1_TabPanel2']").click(function(e) {
    var container = $find('TabContainer1');

    e.preventDefault(); //works for anything with preventDefault (e.g., not called from html onclick, etc.)

    $("[id$='Button1']").click();   //perform the button1 click event (which calls custom validation)

...
Doug
  • 3,312
  • 1
  • 24
  • 31
  • Unfortunately, I tried this. No luck. No matter what I do, IE8 refuses to not skip the tab. Maybe it has something to do with declaring the TabPanel1 as ? I've had a hard time with anything ajax since I started programming - I don't fully understand it. – user1585004 Dec 13 '12 at 17:24
  • Hmmm, is there any chance you can jsfiddle it? If that didn't work then I'm somewhat at a loss without the code. – Doug Dec 14 '12 at 16:11