Morteza
Morteza

Reputation: 444

CRM 2013 Limit the date field

I have 3 date and time fields (its date only). But I want to limit the user not to be able to select future date. I mean dates after today's couldn't be selected in the date picker. How can I do it?

Upvotes: 0

Views: 753

Answers (2)

Adi Katz
Adi Katz

Reputation: 548

Crm datetime field doesn't support this type of functionality. You'll need to create your own html webresource and use a well-known library / control such as jquery datepicker. Once you have the resource in place syncing the picker value with the hidden datetime value should be relatively easy using the form onload and onsave events.

Upvotes: 1

Rickard N
Rickard N

Reputation: 408

You have to write a validator, either in plugin or JavaScript (or business rules), or perhaps both. JS only works in the forms but has the possibility to give a prettier error message, with the business rules you can have a valitation which gives messages inline. If you only add data using the GUI, it might be enough to just use JS/business rules but if data can come any other way I would secure it with a plugin as well.

The validator is pretty simple, retrieve the field and compare it with a date object today. It could be a bit worse if there are a lot of timezones involved, we don't like timezones....

Upvotes: 1

Related Questions