Confiforms date picker validation to prevent users from picking days in the past
Asked by Curtis Freudigmann:

As the title suggests I am looking for a way to prevent my users from selecting a date before the current day in a date picker in a Confiforms form. I know that there is an option to add regex. Has anyone tried this? Any suggestions would be appreciated.

Thanks!

-Curtis


Answers:
author: Alex Medved _ConfiForms_
body: You cannot modify the date picker itself, but you can setup the validation rule for your form to accept the dates after the certain date

[This page demoes the concept and accepts the dates after today](https://wiki.vertuna.com/pages/viewpage.action?pageId=25591937)

comments: author: Curtis Freudigmann
body: Hey Alex! I was able to follow the link and get the example form in to my space. I have the validation working and it sends my error message. The issue I am facing now is that my forms have multiple date pickers. Certain date pickers are only shown when other fields are selected. For example: I have a normal request and a miscellaneous request in the same form. the fields differ depending on if Normal or Miscellaneous is selected in the drop down. If the user selects Normal, and fills out all accompanying information the form will not submit because the date picker in Miscellaneous is not passing validation because the empty picker is not showing as a date in the future. Am I able to set multiple conditions? Or would I need to set up an extra rule somehow?

As always thanks for the great responses!

-Curtis


author: Alex Medved _ConfiForms_
body: Well, just tune the condition in the rule to only apply when necessary

Meaning something like - when the selection in some other field matches some value and the date is not empty and not after "today" then show the error message

For example, [like is shown here - we only "require" field value when the other field is checked](https://wiki.vertuna.com/display/CONFIFORMS/Conditional+validation+for+required+field)


author: Curtis Freudigmann
body: Thanks Alex! I was trying \&\& instead of AND which was not working. I made this simple correction and it works as expected. ?


author: Curtis Freudigmann
body: Hey Alex, I am working on something very similar to this but have ran in to small snag. I need to let users select a date that is today and forward. Using the mydate:\<\[now\], the user has to go in and move the clock to a minute ahead to all them to pass the validation. Is there a way to set something like mydate:\<\[now\]-1 minute.? That way I can set \[now\] as the default starting interval and still pass validation.

Please let me know. Thanks!

-Curtis


author: Alex Medved _ConfiForms_
body: Try

```
mydate:<[entry._today]
```

As per <https://wiki.vertuna.com/display/CONFIFORMS/Accessing+field+values+and+properties#Accessingfieldvaluesandproperties-Additionalvaluesavailableinthecontext>


author: Curtis Freudigmann
body: This works exactly as I was hoping. Thanks Alex!


author: Jonathan Saldarriag
body: Hi [@Alex Medved _ConfiForms_](/t5/user/viewprofilepage/user-id/781630) I am trying to set a validation rule for a date field called deadline. The field is controlled by another one that has only two options (newCustomer, existingCustomer). What I want to achieve is. If newCustomer is selected the user cannot select today as the date, so basically today should be block (see attached images). If existingCustomer is selected then the user should have a block of 10 business days and only that day after can be selected (see images for representation). Right now, I have set up two rules definitions where the validation code is as follow:  
Option1  
deadlineSubmission:\>\[entry._today\] AND typeCustomer:newBusiness  
Option2  
deadlineSubmission:\>\[entry._today\]+10 AND typeCustomer:existingCustomer  
I am tracking the two fields but it is not working, I can select any dates and today's date with no warning or error. Please let me know what am I doing wrong.  
![Image 12.09.24 at 16.24.jpeg](https://community.atlassian.com/t5/image/serverpage/image-id/347107iB3714DFF9407E55D/image-size/large?v=v2&px=999 "Image 12.09.24 at 16.24.jpeg")  

![image (2).png](https://community.atlassian.com/t5/image/serverpage/image-id/347104iE68E39DBA81FEEC1/image-size/large?v=v2&px=999 "image (2).png")![image (3).png](https://community.atlassian.com/t5/image/serverpage/image-id/347105i6E2651AE38808DD4/image-size/large?v=v2&px=999 "image (3).png")

comments: author: Alex Medved _ConfiForms_
body: **Validation** rule with a condition like below

```
deadlineSubmission:<`([today]+``10``))` AND typeCustomer:existingCustomer
```

Alex


author: Jonathan Saldarriag
body: Perfect, thank you, it works. But for the first one I could not make it work, where it is simply avoiding today. I tried these three combinations but I was still able to select today:

```
deadlineSubmission:<`([today]``))` AND typeCustomer:newBusiness
```

deadlineSubmission:\<`([today]``)` AND typeCustomer:newBusiness

deadlineSubmission:\<`[today]` AND typeCustomer:newBusiness

Also, as a further questions. This only gives the error at the end where the user tries to save the entry. Is there anyway that can be block directly while the user is selecting the date? Or even have it graded out like in the calendar like shown in the images?


author: Alex Medved _ConfiForms_
body: Again, a validation rule, with a given condition

```
deadlineSubmission:[entry._today] AND typeCustomer:newBusiness
```


author: Jonathan Saldarriag
body: Thank you, it works now. For the other questions I am assuming then it is not possible? To gray it out or being corrected in user actions instead of waiting until the user tries to save the entry?  
Also, is there anyway to modified the little calendar so the week starts at Monday instead of Sunday. I follow several post in Confluence and change the starting day in the settings. But it only affected teams Calendar and not the one that is shown in the field when user tries to choose a date.


author: Alex Medved _ConfiForms_
body: There are no built-in options to modify the date picker at the moment in ConfiForms


author: Ross Strachan
body: I just cannot get this to work......Field is called Desired Launch Date

Set the validation on the field to DesiredLaunchDate:\<\[entry._today\]

Added a validation defition and set that to the same DesiredLaunchDate:\<\[entry._today\]

Still lets me pick any date I want. Clearly i'm misunderstanding and doing something wrong.

:(

comments: author: Alex Medved _ConfiForms_
body: Hi

You cannot prevent this in UI, but you can validate the data submitted and prevent this from being submitted

Have you set this as a condition in your ConfiForms Field Definition Rule?

Have you also selected action to be "validate" and defined the message to show when the validation fails?

Alex


author: Ross Strachan
body: So on the field, I have validation set to DesiredLaunchDate:\<\[now\] on the field - no separate field definition rule.

But this fails ALL the time. I can't pick any date. I just want to block future dates.

Do I need to use the additional field definition rule?


author: Ross Strachan
body: Ah - that was my issue - its working now! Thanks for you help!!!


Tags: confiforms

confluence-server

server

validation