Rule to hide fields when an invalid date is manually entered

Jason Walsh May 5, 2021

Good afternoon!

Sounds simple but I've hit a roadblock. I'm looking for a simple rule for field definition that would hide the rest of a form if the a date field was manually entered incorrectly. 

For example, I'm using the default formatting of (MMM dd, yyyy) so calendar picked dates should work without issue, however, if someone were to type in "01/01/2020" or "qwerty" I'd want the rule to kick in, hide the form and pop up an error info field. Is there a quick and easy way to do this? 

1 answer

1 accepted

2 votes
Answer accepted
Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 5, 2021

You can validate your date, and it's timestamp property in particular

As the date that cannot be parsed usually is set to January 1st 1970 at midnight GMT (Greenwich Mean Time) 

So, you can check if it is larger than that or not (which is 0 timestamp)

Something like this: http://recordit.co/YtTD6AG48G 

Alex

Jason Walsh May 5, 2021

This is great! Works well, but what if a user types in a number, like "1" or "123"? Since the date field is numeric, the timestamp logic doesn't appear to catch just a random number. Is there a workaround to prevent that?

Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 5, 2021

You can make it validate agains some other value than 0

For example, the date should be not before January 1 2021

Checking that it is larger than 1609459200000

Suggest an answer

Log in or Sign up to answer