techouse / intl-date-time

International DateTime for Laravel Nova
MIT License
57 stars 21 forks source link

Feature Request: Add Mask to input. #2

Closed wemersonrv closed 5 years ago

wemersonrv commented 5 years ago

Hi. Great file.

Please add maskinput feature to be used with localization/format.

Example: If define a pt localization, uses the slash(/) as mask element... if use DD/MM/YYYY format, uses the slash too... if uses time, uses : too... point, dash, etc... of couse, depending on the display formatting.

techouse commented 5 years ago

Hello @wemersonrv

You can use your own custom date format the same as you would with the standard Laravel Nova DateTime field

Date::make('Created At')->format('DD MMM YYYY')

So I think this issue is already covered unless I understand you incorrectly.

wemersonrv commented 5 years ago

Hello @wemersonrv

You can use your own custom date format the same as you would with the standard Laravel Nova DateTime field

Date::make('Created At')->format('DD MMM YYYY')

So I think this issue is already covered unless I understand you incorrectly.

Nope.. it's not covered. Formatting the date, will only define it's format, not force typing with the mask. My suggestion is to add the mask chars automatically when typing. So users cannot type these chars. For exemple:

Brazilian date DD/MM/YYYY --> ##/##/#### user type 14051973 and field shows 14/05/1973 Brazilian time HH:mm:ss --> ##:##:## (11:59:38) Brazilian Datetime DD/MM/YYYY HH:mm:ss --> #### ##:##:## (14/05/1973 11:59:38) US Datetime: MM-DD-YYYY hh:mm:ss --> ##-##-#### ##:##:## (05-14-1973 11:59:38) MySQL datetime: YYYY-MM-DD hh:mm:ss --> ####-##-## ##:##:## (1973-05-14 11:59:38)

Or any other mask chars: - /.

techouse commented 5 years ago

Aha I see. Will look into it when I have more time on my hands. You are of course very welcome to make a PR :)

techouse commented 5 years ago

Added in v1.1.0. It uses vue-the-mask to do the masking.