Date time component in interface

Certified Senior Developer

Hi All,

I am using a date time component inside the interface. But it also accepting the special characters if we enter manually. After submitting, it is displaying the system date.

Eg: I gave 12/06/2024* 5:00 PM. After submitting it is displaying system date and time. Is there any way to restrict the user entering the special characters inside a date time component or show any validation message based on some condition. 

It would be very helpful if I could able to achieve

Thanks

  Discussion posts and replies are publicly visible

Parents Reply
  • 0
    Certified Senior Developer
    in reply to srinivaasant574373

      
    You should restrict users from adding special characters. I've implemented validation using a regular expression to catch some special characters. I recommend implementing a similar approach for your validation.

    a!localVariables(
      local!dateTime,
      {
        a!dateTimeField(
          label: "Date & Time",
          labelPosition: "ABOVE",
          value: local!dateTime,
          saveInto: local!dateTime,
          validations: if(
            regexmatch(
              tostring(local!dateTime),
              "[$&+,;=?@#'<>.^*()%!]$"
            ),
            "Special Character Found",
            {}
          )
        )
      }
    )


    Keep me posted.

Children