- 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 05:37 AM
anyway other way is change the format in script itself that would also work.
Sample 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');
}
Note: Script has been Tested on PDI and working fine.
Make the field changes based on what you have on your form.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2019 03:48 AM
Hi,
Try this
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var dt = g_form.getValue('date'); // add your field here
var ab = dt.split(' ');
var dte = ab[0];
var op = dte.split('-');
var op1 = op[2];
alert("Date :: " +op1); // Here 'op1' will give you date & you can use it anyplace
if(op1 == '00' ||op1 == '06'){ // Here how could be date "00" ?
alert(' Your Alert Msg');
g_form.setValue('date',''); // add your field here
}
}
Mark it correct/helpful if it helps you
Regards,
Vaibhav Chaudhari
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2019 04:10 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2019 04:24 AM
can you post your current script ?
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2019 04:33 AM
This works fine in my PDI, make sure you have selected the right field for on change field and field is on the form
, this example is for resolved at field
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var dt = g_form.getValue('resolved_at');
var objdate= new Date(dt);
var selday=objdate.getDay();
if(selday == '0' ||selday == '6'){
alert(' Select a week day');
g_form.setValue('resolved_at','');
}
}