Validate dates and times

Hello! I need help :)

I have a doubt that I do not know how to do it.

I want to validate the hours field and the minutes field in this way:

• From April 1 to September 30, effective hours will be 7.

• From October 1 to March 31, the effective hours will be 7 and the minutes will be 33.

in my code:

a!sideBySideItem(
item:

a!integerField(
labelPosition: "ABOVE",
value: ri!Regis.hours,
saveInto: {ri!Regis.hours},
align: "LEFT"
),
width: "MINIMIZE"
),
a!sideBySideItem(
item:
a!textField(
labelPosition: "ABOVE",
value: " Hours ",
readOnly: true
),
width: "MINIMIZE"
),
a!sideBySideItem(
item:

a!integerField(
labelPosition: "ABOVE",
value: ri!Regis.minute,
saveInto: {ri!Regis.minute}
),
width: "MINIMIZE"
),
a!sideBySideItem(
item:
a!textField(
labelPosition: "ABOVE",
value: " Minute",
readOnly: true
)
)

thanks so much!!

  Discussion posts and replies are publicly visible

Parents Reply Children
  • load(
      local!date: today(),
      local!hours,
      local!minute,
      local!validationData: if(
        and(
          local!date >= todate(
            concat(
              "04/01/",
              year(
                local!date
              )
            )
          ),
          local!date <= todate(
            concat(
              "09/30/",
              year(
                local!date
              )
            )
          )
        ),
        {
          hours: 7,
          minutes: 0
        },
        {
          hours: 7,
          minutes: 33
        }
      ),
      {
        a!sideBySideLayout(
          items: {
            a!sideBySideItem(
              item: a!integerField(
                labelPosition: "ABOVE",
                value: local!hours,
                saveInto: {
                  local!hours
                },
                align: "LEFT",
                validations: if(
                  isnull(
                    local!hours
                  ),
                  {},
                  if(
                    local!hours > tointeger(
                      local!validationData.hours
                    ),
                    "Not Valid",
                    {}
                  )
                )
              ),
              width: "MINIMIZE"
            ),
            a!sideBySideItem(
              item: a!textField(
                labelPosition: "ABOVE",
                value: " Hours ",
                readOnly: true
              ),
              width: "MINIMIZE"
            ),
            a!sideBySideItem(
              item: a!integerField(
                labelPosition: "ABOVE",
                value: local!minute,
                saveInto: {
                  local!minute
                },
                validations: if(
                  isnull(
                    local!minute
                  ),
                  {},
                  if(
                    local!minute > tointeger(
                      local!validationData.minutes
                    ),
                    "Not Valid",
                    {}
                  )
                )
              ),
              width: "MINIMIZE"
            ),
            a!sideBySideItem(
              item: a!textField(
                labelPosition: "ABOVE",
                value: " Minute",
                readOnly: true
              )
            )
          }
        )
      }
    )

    so when your form is loading ,we are saving date in a local variable based on local date local variable ,we are getting validation data,

    like if date is in between 04/01/year and 09/30/year the the   validation data will be 

    {
    hours: 7,
    minutes: 0
    }

    other than that the validation data will be

    {
    hours: 7,
    minutes: 33
    }

    so if user enter more values than that then showing a validation message  like "Not Valid "