- 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:21 AM
Hi,
The code provided by @Harshvardhan is correct and it should work not sure why it's not working.
However, I have modified the code as below:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var selday=newValue.getDay();
var res = parseInt(selday);
alert(res);
if(res==0||res==6)
{
alert('select business day');
g_form.setValue('date','');
}
}
Please try once and let me know if it's working or not..
Regards,
Alok
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2019 05:19 AM
Harsha script is working good, no problem with that
i have tested his script in my PDI's working fine , here i didn't uderstand that same script placed in Client environment it giving "NaN" alert message
var seldate=g_form.getValue('date');
var objdate=new Date(seldate);
var selday=objdate.getDay();
var res = parseInt(selday);
alert(res); alert like "NaN" in client Environment only , working fine in my PDI
if(res==0||res==6)
{
alert('select business day');
g_form.setValue('date','');
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2019 04:27 AM
i tested the code which i have provided and its not giving me NAN on my personal instance.
- 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 05:27 AM
the change which you have made in the properties , that's the reason you are getting NAN.
if you can made the changes in below format it will work.
Data Format : yyyy-MM-dd