The below is what I am supposed to do:
Please label this field as “Date of Mailing” on the UI
This field should display under Cancellation Effective Date
The name should be dateOfMailing
The default value should be todays date
Add a validation rule to prevent a date prior to todays date (The cancellation effective date field has similar logic you can use as an exam
I am having trouble with the validation rule.
I did:
{
"type": "date",
"name": "dateOfMailing",
"description": "Date of Mailing",
"dataType": "string",
"required": true,
"format": "date",
"width": "400",
"emitBlur": true,
"defaultValue": "new Date().toISOString().split('T')[0]",
"validationRule": "dateOfMailing; new Date({0}) <= new Date().setHours(0,0,0,0)",
"errorMessage": "*Date of Mailing must be today or later"
},
also tried:
"validationRule": "dateOfMailing; new Date({0}) < new Date().setHours(0,0,0,0)",
"validationRule": "dateOfMailing; new Date({0}) > new Date().setHours(0,0,0,0)",
Error shows when a future date is picked.
I expect validationRule is defining what is acceptable. If so, unacceptable date input should trigger errorMessage.
Rule with
<=means input date earlier than current is acceptable and future date is not.Change operator to
>=as input date greater than or equal to current is valid.However, attempt using
>should have allowed future date but not current.