Cognito-forms – How to program a warning note if order date is past a certain number of days

cognito-formsecommerce

In Cognito Forms how do I program a warning note to appear on the form if the selected order date is past a certain number of days?

This is for an RMA Form on an eCommerce website.

Best Answer

To show a warning note on a return merchandise authorization (RMA) form that only appears if the order was placed after the store's time limit for returns is, add a Date input field to the form and label it "Date of Purchase", then in the Date Field's Show Custom Error setting select "When" and add the following Custom Expression:

=DateOfPurchase<DateTime.Today.AddDays(Int32(-30))

The -30 in the custom expression can be changed to any number of days that you want, such as -90 for 3 months or -365 for one year.

Then add whatever text you want to the Custom Error's error message such as "Returns are only accepted within 30 days after the item was purchased. Unfortunately if you submit this form your return will be denied."

Also in the Date Field Setting's "Range" setting you can leave the minimum value blank and type "Today" into the maximum setting so dates after today can not be accidentally selected.