Hi Team,
I have a requirement wherein I have to choose a date between a specified range.
minDate: today()
maxDate: 31/12/currentYear
Below is the code snippet which works on plunker but not on my code repo:
JSON{
"type": "text",
"name": "daysLeftToExpire",
"defaultValueExpression": "diffDays(getTodayDate(\"MM/dd/YYYY\"),'12/31/'+{getCurrentYear})"
},
{
"type": "datepicker",
"name": "eff_change_date",
"title": "Eff. Change Date",
"isRequired": true,
"inputType": "date",
"dateFormat": "dd/mm/yy",
"minValueExpression": "today()",
"maxValueExpression": "today({daysLeftToExpire})",
"requiredErrorText": "This field is required",
"placeHolder": "Enter effective date",
"width": "40%"
},
Hello Akanksha,
The
minValueExpression
andmaxValueExpression
settings allow you to specify the range of values for a particular question. I updated your JSON and hardcoded thedaysLeftToExpire
question value. Adatepicker
widget appears correctly: View Demo.{ elements: [ { type: "text", name: "daysLeftToExpire", defaultValue: "3" }, { type: "datepicker", name: "eff_change_date", title: "Eff. Change Date", isRequired: true, inputType: "date", dateFormat: "dd/mm/yy", minValueExpression: "today()", maxValueExpression: "today({daysLeftToExpire})", requiredErrorText: "This field is required", placeHolder: "Enter effective date", width: "40%" } ] }
I see that you use the
getTodayDate
function and thegetCurrentYear
question placeholder. Is thegetTodayDate
a custom function?Yes, those are the custom functions… The above code snippet works properly/as expected on plunker but not on my project repo.
Does it requires any specific version to support the above feature.
I'm using is -
Angular 14
jquery 3.6.0
Hello,
Please make sure you are using the same SurveyJS versions in your project and in plunker.
Thank you,
Andrew
SurveyJS Team