How to prevent selecting future date in a date field

Hi Team,

I would like to prevent selecting the future date in the date field.
Kindly help me with any insight on this.

Note: All the future date should be greyed out and is not able to select (if it is clicked it shouldn't be selected or populated in the date field).

 

 

 

Thanks in Advance!

Regards,

Bhoobalan P.

Like 0

Like

3 comments

Hi Bhoobalan,

 

Please use the column validator instead that will do the same task:

setValidationConfig: function() {
              this.callParent(arguments);
              this.addColumnValidator("UsrDatetime1",this.dateTimeColumnValidator);
            },
          	dateTimeColumnValidator: function(){
              console.log(this.get("UsrDatetime1"));
              var invalidMessage = "";
              console.log(this.getSysDefaultValue(Terrasoft.SystemValueType.CURRENT_DATE_TIME));
              if (this.get("UsrDatetime1")>this.getSysDefaultValue(Terrasoft.SystemValueType.CURRENT_DATE_TIME)){
               	invalidMessage = this.get("Resources.Strings.ErrorMessage");
              } 
                return {
                  invalidMessage: invalidMessage
                };
              },

Just replace the UsrDatetime1 column with your date\rime column name and also create a localizable string with the "ErrorMessage" code.

 

Best regards,

Oscar

Oscar Dylan,

Thanks much for the precious response!

But still we could select the future date value, And after validation we throw a error message below the corresponding field name. 

We need to block selecting the future date, which could be possibly achieved via Jquery as below,

$("#dateField").datepicker({
    maxDate: 0
});

How could we achieve the same in our CREATIO Date field ?

Regards,

Bhoobalan P.

Bhoobalan Palanivelu,

 

This validator will also return a validation message upon saving a record with an incorrect date, so it's not possible to select the date\time grater than the current date\time:

And this is much easier than creating a custom logic for the date selector modal window so please use this approach.

 

Best regards,

Oscar

Show all comments