I have a date time picker as a calendar. is there anyway that i avoid backdating in the calendar ? It should be only pick today and future dates.
Thank you all.
Attribution to: user7307
Possible Suggestion/Solution #1
There is no way to control the date picker in salesforce.I think you neeed to use jquery calendar to avoid backdating.
http://jsfiddle.net/antelopelovefan/ZW7cs/34/
$(document).ready(function() {
$('#Date').datepicker({
onSelect: function(dateText, inst) {
//Get today's date at midnight
var today = new Date();
today = Date.parse(today.getMonth()+1+'/'+today.getDate()+'/'+today.getFullYear());
//Get the selected date (also at midnight)
var selDate = Date.parse(dateText);
if(selDate < today) {
//If the selected date was before today, continue to show the datepicker
$('#Date').val('');
$(inst).datepicker('show');
}
}
});
});
Attribution to: sfdc
Possible Suggestion/Solution #2
Not sure if there is a way to have a client side restriction on date range. Alternatively you can apply a validation rule
on the field to keep the data as you need.
If your field is of type Date
,
Your_Field < TODAY()
If your field is of type DateTime
,
DATEVALUE(Your_Field) < TODAY()
Also make sure to do the data cleanup for the existing data if you are applying such a validation. If not the reports will show unacceptable data to your managers ;)
Attribution to: highfive
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/31102