Skip to main content
varunb579494
August 3, 2022
Question

Date validation

  • August 3, 2022
  • 4 replies
  • 0 views

I know this may sound little trivial but I couldn't figure out the logic.

I want a button should be enabled before 5 calendar days from the last date of the month to the first 3 calendar days of next month.

Example from if it's Aug, then it should enable on 26 Aug and stay enabled until 3 Sept.

Any help appreciated.

4 replies

csteward
August 3, 2022

Try this.  Since today is Aug 3, it will be enabled, toggle the commenting on lines 2 and 3 to see how it would act tomorrow (disabled):

a!localVariables(
  local!date: today(),
  /*local!date: today()+1,*/
  local!daysInMonth: daysinmonth(month(local!date),year(local!date)),
  local!day: day(local!date),
  local!dayDisabledStart: 3,
  local!dayDisabledEnd: local!daysInMonth-5,
  {
    a!buttonArrayLayout(
      align: "START",
      buttons: {
        a!buttonWidget(
          label: "Button",
          disabled: not(
            or(
              local!day<=local!dayDisabledStart,
              local!day>=local!dayDisabledEnd,
            )
          )
        )
      }
    )
  }
)

varunb579494
August 4, 2022

That works perfectly, thanks [mention:124cfac3ed754d2d8c4a043c0b4591cf:e9ed411860ed4f2ba0265705b8793d05]

August 4, 2022

Hey varun, Could you please the attached code once please

a!localVariables(
  /*your actual date*/
  local!data:today()-7,
  /*getting last 5th date of the month*/
  local!startDate: eomonth(local!data,0)-5,
   /*from the last 5th date adding 8 to go to next month's 3rd day*/
  local!endDate:local!startDate+8,
  
  a!buttonLayout(
    showWhen: and(
      local!startDate

August 4, 2022

I am so sorry, for disable please try this code.

a!localVariables(
  /*your actual date*/
  local!data: today() - 7,
  /*getting last 5th date of the month*/
  local!startDate: eomonth(local!data, 0) - 5,
  /*from the last 5th date adding 8 to go to next month's 3rd day*/
  local!endDate: local!startDate + 8,
  a!buttonLayout(
    primaryButtons: {
      a!buttonWidget(
        label: "Submit",
        disabled: not(
          and(
            local!startDate < today(),
            today() < local!endDate
          )
        )
      )
    }
  )
)