You need to sign in to do that
Don't have an account?
Mitesh Saparia 8
custom DatePicker not getting value in database?
<apex:page standardController="Contact" extensions="datepickerController" docType="html-5.0" >
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.3.0/css/datepicker.css"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.3.0/js/bootstrap-datepicker.js"></script>
<script>
$(function () {
$("#datepicker").datepicker({
format: "dd/mm/yyyy",
autoclose: true,
todayHighlight: true
}).datepicker().val();
});
function getValues(element){
console.log(element.value);
}
</script>
<apex:pageMessages />
<apex:sectionHeader title="Date Picker" subtitle="Create Contact" />
<apex:form id="frm">
<apex:pageblock title="Contact" id="pb">
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Cancel" action="{!Cancel}" />
</apex:pageBlockButtons>
<apex:pageBlockSection id="pbs">
<apex:inputField value="{!Contact.Salutation}" />
<apex:inputField value="{!Contact.FirstName}" />
<apex:inputField value="{!Contact.LastName}" />
<apex:inputField value="{!Contact.Birthdate}" />
Birthday :--- <input type="text" id="datepicker" onchange = "getValues(this);" value="{!Contact.Birthdate}" />
<apex:pageBlockSectionItem >
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageblock>
</apex:form>
</apex:page>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.3.0/css/datepicker.css"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.3.0/js/bootstrap-datepicker.js"></script>
<script>
$(function () {
$("#datepicker").datepicker({
format: "dd/mm/yyyy",
autoclose: true,
todayHighlight: true
}).datepicker().val();
});
function getValues(element){
console.log(element.value);
}
</script>
<apex:pageMessages />
<apex:sectionHeader title="Date Picker" subtitle="Create Contact" />
<apex:form id="frm">
<apex:pageblock title="Contact" id="pb">
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Cancel" action="{!Cancel}" />
</apex:pageBlockButtons>
<apex:pageBlockSection id="pbs">
<apex:inputField value="{!Contact.Salutation}" />
<apex:inputField value="{!Contact.FirstName}" />
<apex:inputField value="{!Contact.LastName}" />
<apex:inputField value="{!Contact.Birthdate}" />
Birthday :--- <input type="text" id="datepicker" onchange = "getValues(this);" value="{!Contact.Birthdate}" />
<apex:pageBlockSectionItem >
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageblock>
</apex:form>
</apex:page>
if I am not wrong then you are trying to populate the contact.BirthDate field?
if that's is right then first thing you have to change the date format from dd//mm/yyyy to mm/dd/yyyy.
then in on change add following code
document.getElementById('{!$Component.frm:pb:pbs:contactBDate}').value=element.value;