how to restrict dates in datetime field - Sugarcrm

809 Views Asked by At

I am trying to restrict users selecting between dates, but I didn't find a solution to it. I tried the following initiatives to do it.

this.$("input[name='date_c']").datepicker({ maxDate: 1 });

How can I utilize the

_setupDatePicker

Function to restrict the user, is there some configuration to it?

2

There are 2 best solutions below

0
On

if you check task module then Sugar manage this in task module for date start and date end but not in your required way i.e. disable dates but it restrict user to select due date greater then date start. It uses following code:

addToValidateDateBefore('EditView', 'date_start', 'datetimecombo', false,'Start Date', 'date_due' );
0
On

Inside include\javascript\calendar.js Search for calendar.cfg.setProperty("selected", sanitizedDate) this line and below that line add folowing lines

if(inputField==<id of the field> ){
 calendar.cfg.setProperty("maxDate", <maximum Date>); 
 calendar.cfg.setProperty("minDate", <Minimum Date>); 
       }

replace appropriate dates inside maximum date and minimum date