Formatting a dateTime in Web Form similar to InputMask

633
1
09-26-2019 07:10 AM
Chris_Anderson
Occasional Contributor II

I have a public-facing survey working well using the desktop/mobile app and am modifying it to work on the Web. During the testing phase, one of testers has noted that the manual input of a date into a dateTime question allows the user to input a dates that are physically impossible (e.g. 123/4567/8901); we know a hunter somehow would input a date like this. I have tried some methods for restricting the input to MM/DD/YYYY to match the desktop/mobile app with little success. I have seen where I can use a regular expression to do this. I think the syntax would be regex(.,'^\d{1,2}"/"\d{1,2}"/"\d{4}$'). I also am not sure which column this would be placed.

Any help with this is greatly appreciated.

Chris Anderson

Florida Fish and Wildlife Conservation Commission

0 Kudos
1 Reply
IsmaelChivite
Esri Notable Contributor

Hi Chris. Thanks for posting your question. Unfortunately it is not possible to prevent a user (particularly a hunter ) to enter an incorrect date in the calendar control. However, you may want trying with a constraint. For example, what if you limit the user input through a constraint to a 'reasonable' time range?  Say for example anything between today and 1940, or anything between today and 2025, or anything between 1940 and 2025.  The syntax to create this type of constraints is described in https://community.esri.com/groups/survey123/blog/2016/04/17/dates-and-time-in-survey123-for-arcgis 

The constraint will not prevent the user to enter an incorrect date, but will prevent the user from submitting the data until the date is within range (no pun intended).

By the way, congrats for your work with Survey123 at the Florida Fish and Wildlife Conservation Commission.  Really nice job!

0 Kudos