Restrict previous dates in calendar
Many time will come across scenarios where date picker should not allow user to select previous date (i.e. dates smaller than current date). But if will look at Smartform Date picker control, there is no property which allow us to stop user from selecting previous date.
Below is an example with 3 simple step, which provide this functionality in date picker control .
Step 1 : Add Controls to Layout
- Drag and drop calendar control from controls menu available on Right Hand Side to layout page and add a datalabel on top of this control to show message to user.
- Now Select the calendar control which will show the Properties on right hand side, do the changes for Calendar control per your requirement. In my case I have Selected “Data Type “and “Picker Type” as Date, Date format to English (United Kingdom).
Step 2: Create Data Label Control to Add Expression
- Uncheck visible property
- Check Literal Property
- Now click on ellipse Next to Expression property. This will show popup to “add/remove expression”.
Click on add and add expression as shown in below Image
- Save this and close Expression Popup. While closing expression, popup select none as Expression
Step 3 : Add Rule to Calendar control
- Add rule to check when Calendar value is changed then execute Expression
- Then add if condition to check if calStartedDate contains EmptySpace.
- If condition is true, then set Error message to Data Label and keep Visible value as true
- Else keep message Text empty and visible value as false.