You need to sign in to do that
Don't have an account?
Jaanu
How to create date of birth field on visual force page
Hello! I am trying to create an account using visual force page. Note that we have person accounts activated. I am just entering first name, last name, date of birth using VF page. When I try to test it ... I am good with fn, ln. When it comes to DOB, I select the date... but the date disappear as soon as my mouse is off of the field...and defaults to mm/dd/yyyy. After I click next, the record is saved with fn, ln... no DOB. Pls help me what's wrong here...thanks.
<apex:page standardController="Account" docType="html-5.0">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:pageBlock title="Account Creation">
<br>
<apex:pageblocksectionitem >
<apex:outputlabel value="First Name "/>
<apex:inputText value="{!account.firstname}" id="personFname"/>
</apex:pageblocksectionitem>
</br>
<br>
<apex:pageBlockSectionItem >
<apex:outputlabel value="Last Name " for="personLname"></apex:outputLabel>
<apex:inputText value="{!account.lastname}" id="personLname"/>
</apex:pageBlockSectionItem>
</br>
<br>
<apex:outputlabel value="Date of Birth " for="persondob"></apex:outputLabel>
<apex:inputfield type="date" value="{!Account.PersonBirthdate}" style="width:150px" id="persondob"/>
</br>
<apex:commandButton id="saveBtn" value="Next" action="{!Save}" />
</apex:pageBlock>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
<apex:page standardController="Account" docType="html-5.0">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:pageBlock title="Account Creation">
<br>
<apex:pageblocksectionitem >
<apex:outputlabel value="First Name "/>
<apex:inputText value="{!account.firstname}" id="personFname"/>
</apex:pageblocksectionitem>
</br>
<br>
<apex:pageBlockSectionItem >
<apex:outputlabel value="Last Name " for="personLname"></apex:outputLabel>
<apex:inputText value="{!account.lastname}" id="personLname"/>
</apex:pageBlockSectionItem>
</br>
<br>
<apex:outputlabel value="Date of Birth " for="persondob"></apex:outputLabel>
<apex:inputfield type="date" value="{!Account.PersonBirthdate}" style="width:150px" id="persondob"/>
</br>
<apex:commandButton id="saveBtn" value="Next" action="{!Save}" />
</apex:pageBlock>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Try for this code.
if this answer is useful for you please choose the best answer
Thanks,
Akhsay
All Answers
<apex:page standardController="Contact" docType="html-5.0">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:pageBlock title="Account Creation">
<br>
<apex:pageblocksectionitem >
<apex:outputlabel value="First Name "/>
<apex:inputText value="{!Contact.firstname}" id="personFname"/>
</apex:pageblocksectionitem>
</br>
<br>
<apex:pageBlockSectionItem >
<apex:outputlabel value="Last Name " for="personLname"></apex:outputLabel>
<apex:inputText value="{!Contact.lastname}" id="personLname"/>
</apex:pageBlockSectionItem>
</br>
<br>
<apex:outputlabel value="Date of Birth " for="persondob"></apex:outputLabel>
<apex:inputfield type="date" value="{!Contact.Birthdate}" style="width:150px" id="persondob"/>
</br>
<apex:commandButton id="saveBtn" value="Next" action="{!Save}" />
</apex:pageBlock>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Try for this code.
if this answer is useful for you please choose the best answer
Thanks,
Akhsay