2

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.

2 Answers 2

0

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 ;)

1
  • If you have a DateTime field and you are going to do a data migration for that, take care about the timezone difference. Because we should consider that Saleforce keeps DateTime field values as GMT and they will be converted into user's timezone when rendering on pages
    – highfive
    Commented Apr 1, 2014 at 3:52
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');
        }
    }
});

});

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .