You need to sign in to do that
Don't have an account?
Rajesh-SFDC
getElementById is not checking the value returning null
Hi All,
I am facing issue get elemnet by id in below function returning null even putting value into the field .Below is my code
<apex:page STAndardController="Candidate__c" tabStyle="Candidate__c" id="a" >
<script>
{
alert("Email Address Mismatch"+document.getElementById("{!$Component.a.b.c.d.email}"));
return false;
}</script>
<apex:pageMessages />
<apex:form id="b">
<apex:pageBlock title="New candidate" id="c">
<apex:pageBlockSection title="Information" columns="2" id="d" >
<apex:inputField value="{!Candidate__c.Title__c}"/>
<apex:inputField value="{!Candidate__c.First_Name__c}"/>
<apex:inputField value="{!Candidate__c.Last_Name__c}"/>
<apex:inputField value="{!Candidate__c.SSN__c}"/>
<apex:inputField value="{!Candidate__c.Gender__c}"/>
<apex:inputField value="{!Candidate__c.DOB__c}"/>
<apex:inputField value="{!Candidate__c.Phone__c}"/>
<apex:inputField value="{!Candidate__c.Mobile__c}"/>
<apex:inputField value="{!Candidate__c.Email__c}" id="email" onkeydown="return DisableCtrlKey(event)" onMouseDown="DisableRightClick(event)"/>
<apex:inputField value="{!Candidate__c.Confirm_Email_Addrees__c}" id="cnfrmemail" onkeydown="return DisableCtrlKey(event)" onMouseDown="DisableRightClick(event)"/>
<apex:inputField value="{!Candidate__c.PAN__c}"/>
</apex:pageBlockSection>
<div align = "Center">
<apex:commandButton action="{!save}" value="SAVE" onclick="return validate()"/>
<apex:commandButton action="{!quicksave}" value="Quick Save"/>
</div>
</apex:pageBlock>
</apex:form>
</apex:page>
here even in the email filed value is there it is returning null your help on this would be great.
i used direct as well as level access of IDs.
I have to access the highlighted the above highlighted field in java script .
I am facing issue get elemnet by id in below function returning null even putting value into the field .Below is my code
<apex:page STAndardController="Candidate__c" tabStyle="Candidate__c" id="a" >
<script>
{
alert("Email Address Mismatch"+document.getElementById("{!$Component.a.b.c.d.email}"));
return false;
}</script>
<apex:pageMessages />
<apex:form id="b">
<apex:pageBlock title="New candidate" id="c">
<apex:pageBlockSection title="Information" columns="2" id="d" >
<apex:inputField value="{!Candidate__c.Title__c}"/>
<apex:inputField value="{!Candidate__c.First_Name__c}"/>
<apex:inputField value="{!Candidate__c.Last_Name__c}"/>
<apex:inputField value="{!Candidate__c.SSN__c}"/>
<apex:inputField value="{!Candidate__c.Gender__c}"/>
<apex:inputField value="{!Candidate__c.DOB__c}"/>
<apex:inputField value="{!Candidate__c.Phone__c}"/>
<apex:inputField value="{!Candidate__c.Mobile__c}"/>
<apex:inputField value="{!Candidate__c.Email__c}" id="email" onkeydown="return DisableCtrlKey(event)" onMouseDown="DisableRightClick(event)"/>
<apex:inputField value="{!Candidate__c.Confirm_Email_Addrees__c}" id="cnfrmemail" onkeydown="return DisableCtrlKey(event)" onMouseDown="DisableRightClick(event)"/>
<apex:inputField value="{!Candidate__c.PAN__c}"/>
</apex:pageBlockSection>
<div align = "Center">
<apex:commandButton action="{!save}" value="SAVE" onclick="return validate()"/>
<apex:commandButton action="{!quicksave}" value="Quick Save"/>
</div>
</apex:pageBlock>
</apex:form>
</apex:page>
here even in the email filed value is there it is returning null your help on this would be great.
i used direct as well as level access of IDs.
I have to access the highlighted the above highlighted field in java script .
You can give class to element and access value of the field like below:
<apex:inputField value="{!Candidate__c.Email__c}" styleClass="emailCls" onkeydown="return DisableCtrlKey(event)" onMouseDown="DisableRightClick(event)"/>
alert(document.getElementsByClassName('emailCls')[0].value);
Hope this helps.