How to disable past dates in Datepicker (sp-date-picker) in service portal and also need to add placeholder
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2018 11:42 PM
Hi,
I am looking for disabling past date selection in sp-date-picker and also i need to have placeholder text for the Datepicker field. Can anyone help me on this?
Regards,
Divya Lakshmi.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2018 11:48 PM
If its form widget you are using then you could write onChange client scripts for date fields. Catalog client scripts for SRs. Try default value in these fields as an alternative to placeholders.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2018 03:34 AM
If you want to do it using script, you can do this
var today = new Date();
var priorDate = new Date();
var currentDateObj = priorDate.setDate(priorDate.getDate());
//get start date
var startDateStr = g_form.getValue('date_field');
var startDateNum = getDateFromFormat(startDateStr, g_user_date_format);
if (startDateNum < currentDateObj) {
alert('Invalid date format Or selected date is in the Past. Select a Future date using date picker');
g_form.setValue('date_field', '');
}
Thanks,
Akash
Mark answer helpful or correct if it helps your case.
