ontabclick event (Tab Panel)



The ontabclick event is activated when a tab is clicked on a Tab Panel or Tab Panel Layout widget.  The special variable tab can indicate the index of the tab that was clicked.  The first tab is index 0, the second tab is index 1, and so on.  If the JavaScript expression evaluates to false, the tab will not be switched.

Note: the event fires before the tab is switched; thus, with the Tab Panel Layout, elements in the new tab are not yet visible when the event code runs.

Example:

The following code requires the user to fill out the information on the first tab before allowing them to switch to the second tab.

ontabclick: processTabClick(tab);

function processTabClick(tab) { if (tab == 1) { if (get("FIELD1") == "" || get("FIELD2") == "") { alert("You must fill out information on the first tab before switching to the second tab."); return false; } } return true; }