How do i  restrict the user to enter only the date in the specified format .

0
Hi I am trying to achieve date in the format of  “ DD/MM/YYYY”  , how do i  restrict the user to enter the date in this format only.
asked
1 answers
1

Because Mendix renders datepickers and <input type=”text”>, I don’t think there’s any default Mendix functionality that restricts users from typing in random characters – however, this doesn’t mean they can attempt to input anything and Mendix will turn it into a date. As your screengrab shows, it will only parse dates if input in a valid format.

If you want to make sure that you get your values in a certain format, you can use this option on your datepicker field

It makes it very easy to achieve.

If you want to actually restrict user input (so, they hit a letter on their keyboard but no input is registered) you’d need some custom JS in a snippet – https://stackoverflow.com/questions/22708434/restrict-characters-in-input-field – this Stackoverflow post and the accompanying Jsfiddle is informative for that. However, I personally don’t think that’s a very friendly bit of design, and think you should allow a user to fail, especially since there’s proper validation in place.

answered