I have one vf page where after clicking on Contacts tab I want check whether user has entered value in "tab1_Name" inputText under AccDetails tab. I am trying to access the "tab1_Name" id using $Component notation, however everytime its value is null. Any help/suggestion will be greatly appreciated.
<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">
function validate()
{
try
{
var fNameObj = document.getElementById('{!$Component.AccountTabPanel.tabdetails.tab1_Id}');
alert("inside validate"+fNameObj);
if(trim(fNameObj.value) == "")
{
alert("tab1Name is mandatory!");
return false;
}
return true;
}
catch(e)
{
alert(e);
return false;
}
}
</script>
</apex:page>