Datetime Typed Input

Is there something similar to FormattedTextField in Perspective?

Especially for dates, clicking 50 times to get to a specific month, year, day, hours and minute is quite annoying and takes longer than just having a specific format muscle memoried. DatetimeInput has a caret in its icon, but as far as I am able to tell, I can’t type into it?

image

I’ve read through the docs and forums and no matter what I do I am forced to use the popup picker? I want to be able to type, and it adds in the dashes, slashes, and spaces. eg. 2026010210000000 becomes 2026-01-02 10:00:00. Am I missing something?

This was an idea for entering IP address, but you might be able to tweak to your use case. I would have an additional confirm button so whatever is tied to the value doesn't thrash while you are entering a value. If you built it in a custom popup then you could send new value on popup close.

I don't think there is anything built in. If you have the resources, a custom module that adds a component specifically for this might be reasonable.

1 Like

In 8.3, the new Form component gives you access to a wide variety of client side validation options:

1 Like

How difficult would it be to bring these validation options over to the regular perspective text field? (And possibly backported to 8.1?)

I guess having the form available eliminates the need for the validation on the regular text entry field?

Validation is one thing, what I mean is more convenience. Like when you type in a phone number or credit card, even dates ive seen do this, and it just adds in the extra stuff for you as you type. I’ve tried doing this a bit with the text field, but it was always kind of a pain. I might be able to do it with an underlying textfield that focuses itself and is invisible. I havent found a satisfactory solution to this, this might be a good foray into perspective component module dev though

The validation and behavior in the form component is basically what's available on the input element: <input>: The HTML Input element - HTML | MDN

A lot of the behavior you get "for free" from the user agent (browser), which gives you better performance and native "feeling" controls (e.g. a specialized popup keyboard on mobile devices for email/telephone entries), vs creating fully custom behaviors that rely on Javascript we bundle and deliver on the page.

That said, it definitely would be possible to create custom components that have some of those niceties.