I have an <apex:tabPanel>
with several <apex:tab>
.
After clicking on one tab, I am doing some validation and depending on the validation result I want to switch to another tab. How to do this from client side (I don't want to write any code for switch tab in controller)?
Here is my VisualForce page :
<apex:page controller="TestController" showHeader="true" >
<apex:form >
<apex:tabPanel switchType="client" selectedTab="tabdetails" id="AccountTabPanel"
tabClass="activeTab" inactiveTabClass="inactiveTab">
<apex:tab label="Details" name="AccDetails" id="tabdetails">
<apex:inputText id="tab1_Id" label="tab1_Name" value="{!AccountList}"/>
</apex:tab>
<apex:tab label="Contacts" name="Contacts" id="tabContact" onclick="validate()">
<apex:inputText id="tab2_Id" label="tab2_Name2" value="{!AccountList}"/>
</apex:tab>
</apex:tabPanel>
</apex:form>
<script language="javascript">
var validate = function(ele)
{
alert("inside validate " +ele);
var fNameObj = document.getElementById('{!$Component.testPage:myform:tab1_Id}').value;
var sNameObj = $$('[id$="tab1_Id"]').value;
console.log("inside validate fNameObj "+fNameObj);
console.log("inside validate "+sNameObj);
if(fNameObj.trim() == "")
{
alert("tab1Name is mandatory!");
return false;
}
return true;
}
</script>
</apex:page>