function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

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" >

alert("Email Address Mismatch"+document.getElementById("{!$}"));
return false;
<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}"/>
<div align = "Center">
<apex:commandButton action="{!save}" value="SAVE" onclick="return validate()"/>
<apex:commandButton action="{!quicksave}" value="Quick Save"/>


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 .
Dushyant SonwarDushyant Sonwar

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)"/>


Hope this helps.

It worked Thanks a lot !! Can you please let me know why getElementByID is not working .