Past Date on Date field should thrown an error near field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2022 04:22 AM
Hi Experts,
My requriement is I have only 1 date field whenever i select past date from today it should show field error message. I tried using UI policy but only for 1st time it's working,if i keep on checking again and again the error is not occuring.
Please somebody help me what is the best approach for this?
Regards,
Gayathri
- Labels:
-
Personal Developer Instance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2022 11:16 AM
Hi Gayathri
If my above response is helpful, then Please mark as Correct Answer/Helpful.
If you have any queries, let us know.
Thanks 🙂
Shakeel Shaik 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2024 10:05 PM - edited 05-06-2024 10:06 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2022 12:26 AM
Hi,
Try Below...It works.
Client Script : Onchange Client Script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var udt = newValue;
var ga = new GlideAjax("GetCurrentDateAndTime");
ga.addParam('sysparm_name', 'GetDate');
ga.addParam('sysparm_get_date', udt);
ga.getXML(HelloWorldParse);
function HelloWorldParse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer == '5') {
g_form.setValue('date_field_name', "");
return false;
}
}
}
Script Include
var GetCurrentDateAndTime = Class.create();
GetCurrentDateAndTime.prototype = Object.extendsObject(AbstractAjaxProcessor, {
GetDate: function() {
var getNum = this.getParameter('sysparm_get_date');
var nd = new GlideDateTime();
if (getNum > nd) {
return 5;
},
type: 'GetCurrentDateAndTime'
});