Our pure JavaScript Scheduler component

Post by nvondru »

I've noticed that by default the timeFields in the event editor have a quite strange behavior. I set the time format to "HH:mm" and so want to be able to only set values from "00:00" to "23:59".
However the input field allows for all kinds of inputs and internally converts them to a datetime (using a logic I don't understand). I'll give you some examples:

Input -> converted dateTime

empty string -> null (makes sense -> also gives a validation error message)
14:30 -> Wed Jan 01 2020 14:30:00 GMT+0100 (Central European Standard Time) (not sure where the date comes from, but also makes sense)
88888 -> Wed Jan 01 2020 16:00:00 GMT+0100 (Central European Standard Time) (why is this input valid?)
abcdef -> Wed Jan 01 2020 00:00:00 GMT+0100 (Central European Standard Time) (why is this input valid?)
123:456 -> Wed Jan 01 2020 10:36:00 GMT+0100 (Central European Standard Time) (why is this input valid?)

Your API doesn't seem to offer any kind of validation out of the box for these cases. Also when adding a listener "onInput" I get the already converted values.

How can I prevent users from entering values they're not supposed to? And if I'm unable to prevent them from doing so, how can I prevent the timeField from convertig such non-sense values into some kind of dateTimes?

My preferred behavior would be:

  • Users can only input numbers
  • a ":" is automatically inserted after the first two numbers are entered
  • a max of 5 symbols can be entered -> e.g. 14:30

Post by nickolay »

Post by nvondru »

Thank you, I got some basic validation working

Post by nickolay »

Glad it works, yw.

Post Reply