Validate END BY field in scheduler


When trying to create recurring event, how can I validate the date entered in ‘end by’ field (in lightbox) is of valid format(mm.dd.yyyy)?
I was able to achieve this by capturing its value (code included below) in onEventSave event handler. However I am not able to figure out which option is selected among “no end date, after occurrences, end by” to apply this validation logic.

      var endByElement = document.getElementsByName('date_of_end')[0] as HTMLInputElement; // end_by field value
      if(endByElement &&  endByElement.value) {
        if (!this.isValidDateFormat(endByElement.value)) {
            text: "Invalid end by date."
          return false;

Screen Shot 2024-04-10 at 12.42.37 AM

Hello @rajeswarij,

Currently, there is no direct way to know which option is selected, but you can check what options are selected with the formSections.getValue() method, like follows:

    var rec = scheduler.formSection('recurring');
    return true;

So before saving the event, you will be able to check the recurring pattern for it through regular expression(or some other way to validate the resulted string), as it will be different for each selected option(check the end of the string):

// no end:

//  after n(5) occurences

// end by

So based on the end of the string, you will be able to check which option is selected.

Kind regards,

Thanks for your input. Let me try this option.

This worked. Thanks for your suggestion.