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
  • FWIW this doesn't appear to actually be doing what you're intending it to do. 

    The dataTime field doesn't actually save any particular value into its target until a valid (complete) date and time is passed in.  I believe your RegEx is just validating against a blank input (as in returning a false positive for an error).

    The thing is, the dateTime field starts evaluating the validations parameter as soon as either side is filled, but this is before the target variable has actually been passed any value.  So any value added at all will cause a validation that matches on a blank value to fire, such as:

    (note how local!dateTime still holds no value here).

    This functionally works the same as the original input with special characters added - it causes no data to actually be passed, apparently:

    Interestingly, this behavior changes when we mark the field as "required":

    But this opens the door to it seemingly working *correctly* (if somewhat unintuitively) when we now click a "submit" button - at least it recognizes there is no value where a required one was expected.

Children
No Data