When leaving a tab panel, the 'onUnselect' event fires. You can use this event to do your detecting login. If you don't allow the user to switch to other tab panels, call 'select' method again on the current tab panel. Please try the code below:
$('#tt').tabs({
onUnselect:function(title,index){
var p = $(this).tabs('getTab', index);
var f = p.find('form');
if (f.length){
if (!f.form('validate')){
$(this).tabs('select', index);
}
}
}
})