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
If I try this, the date time fields just does not accept my entered values.
You wrote: "After submitting, it is displaying the system date". What exactly do you mean with "it" and "system time"?
We have written a code to display the value as some default date if the value is null. Is there a way to restrict the user entering special characters inside a date time component ?
Could you help us with code snippet?
By default we are storing created on date if it is null. If we provide any special characters inside the date time component it is taking it as null.
Is there a way to restrict users entering special characters inside the component?
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", {} ) ) } )
Shubham Aware ,It is working but before providing the time it is throwing validation message. After time is provided the validation is disappeared.
I tried using null check but in Pic 1 and 3 in both scenarios it will be null
Unknown said:I tried using null check but in Pic 1 and 3 in both scenarios it will be null
We are displaying validation for the user to remove special characters from the date. When the user removes those characters, the value becomes available in a variable. Is this not happening?
That is working as expected but the validation message is showing before providing the time.
Shubham Aware anyway we are fine with that. Thank you for your response