Announcement

Collapse
No announcement yet.

restrict field date only week-day or only one day of week

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • restrict field date only week-day or only one day of week

    Hi,

    what's is the best way to restrict user do not enter value in a date field other than :
    - only week-day (only working day : monday->friday)
    - only thuesday (for sample)

    incredible, user fill this date field a saturday, a sunday.. and user don't work.
    Not understand user, this field is "default : today" .. i don't understand why user change this field.

    This field must be editable, because, maybe next thuesday

    Last edited by item; 03-27-2024, 08:20 PM.

  • #2
    Hi Item,

    You can use API Before-Save script and check the date value.

    Code:
    if (
        dateField &&
        (
            datetime\dayOfWeek(dateField, 'Europe/Amsterdam') == 0 ||
            datetime\dayOfWeek(dateField, 'Europe/Amsterdam') == 6
        )
    ) {
        recordService\throwBadRequest("Only weekdays are allowed.");
    }

    Comment

    Working...
    X