- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2019 02:53 AM
Hi,
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var seldate=g_form.getValue('date');
var objdate=new Date(seldate);
var selday=objdate.getDay();
alert(selday);
if(selday==0||selday==6)
{
alert('select business day');
g_form.setValue('date','');
}
}
but i am getting "NaN " value in alert.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2019 06:50 PM
did you try with the code which i have posted ?
Updated Code:
var df = g_form.getValue('u_date');
var op=df.split('/');
var ress=op[2]+'/'+op[1]+'/'+op[0];
var objdate=new Date(ress);
alert(objdate);
var selday=objdate.getDay();
var res = parseInt(selday);
alert(res);
if(res==0||res==6)
{
alert('select business day');
}
Change the field value. if you have a data/time type field then you can follow the same split() to make your data format like yyyy-MM-dd

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2019 04:43 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2019 04:46 AM
i don't want return Date, just it should check "Day"
like if we select Sunday Date Or SaturDay Date it should not accept , it just accept only Monday to Friday Dates only

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2019 05:32 AM
Hi,
Try this,
var gdt = new GlideDateTime(g_form.getValue('date')); // Your "Date" value
alert("GDT :: "+gdt.getDayOfWeek());
if(gdt.getDayOfWeek()==5 || gdt.getDayOfWeek()==6 ){ // Here 5 & 6 are for sat & sun respesctively.
// Do your Stuff
}
else{
// Do your Stuff
}
Hopefully, it will help you.
Regards,
Vaibhav Chaudhari

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2019 05:40 AM
GlideDateTime() works only in server side . you have to change your script from client to server.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2019 07:34 AM
Hi,
Now I try this it will work,
Script Include :
// Create new Script include Function
// Be sure the "Client callable" checkbox is checked
validDate : function(){
var gdt = new GlideDateTime(this.getParameter('sysparm_date')); // Your "Date" value
gs.log("GDT :: "+gdt.getDayOfWeek());
if(gdt.getDayOfWeek()==5 || gdt.getDayOfWeek()==6 ){ // Here 5 & 6 are for sat & sun respesctively.
return false;
}
else{
return true;
}
}
onChange client SCript :
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
if(newValue != oldValue){
var helperGA = new GlideAjax('YOUR_SCRIPT_INCLUDE_NAME');
helperGA.addParam('sysparm_name', 'validDate');
helperGA.addParam('sysparm_date', newValue);
helperGA.getXML(function (response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
// alert(answer);
if(answer == false){
alert('select business day');
g_form.setValue('date','');
}
});
}
}
Regards
Vaibhav Chaudhari