- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2017 01:37 PM
Hi Community,
This is kind of a silly question, but I'm writing a client script that checks to see if a date field is empty. If it is empty I want it to clear a couple other fields:
var start = g_form.getValue('from');
var end = g_form.getValue('to');
if(start=='' || null) {
g_form.setValue('year', '');
g_form.setValue('month', '');
g_form.setValue('day', '');
}
Right now, when I delete the date field, the other fields don't clear out. However, if I delete the date field and press the space bar, the other fields clear out. What's the syntax to see if a date field is empty or not?
Thanks!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2017 08:48 PM
I believe it's because we are checking newValue === '' in onChange() function and then returning from there, kindly replace this line
if (isLoading || newValue === '') {
to
if (isLoading) {
please try with below script and see if that helps:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading) {
return;
}
//Type appropriate comment here, and begin script below
if(newValue == ''){
g_form.setValue('year', '');
g_form.setValue('month', '');
g_form.setValue('day', '');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2017 07:56 PM
hi david,
try the following one-
if (gr.work_start) {
}
thanks ,
vishal

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2017 08:04 PM
Can we try to check newValue object with onChange() client script on from field.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
if(newValue == ''){
g_form.setValue('year', '');
g_form.setValue('month', '');
g_form.setValue('day', '');
}
}
Please check if field name of year, month and day is correct, shouldn't it be start with u_ if it's a custom field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2017 08:39 PM
Hm none of these worked. If I have a date already in there and I change the date, all the other fields recalculate and works great. However, when I delete the date, nothing happens with the other fields, they still retain their original values. It's almost like the onChange client script doesn't recognize the deletion as a change. Any suggestions on how to get this to recognize deletion as an actual change for that field?
Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2017 08:48 PM
I believe it's because we are checking newValue === '' in onChange() function and then returning from there, kindly replace this line
if (isLoading || newValue === '') {
to
if (isLoading) {
please try with below script and see if that helps:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading) {
return;
}
//Type appropriate comment here, and begin script below
if(newValue == ''){
g_form.setValue('year', '');
g_form.setValue('month', '');
g_form.setValue('day', '');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2017 06:44 AM
Amazing, you are solving all of my problems Shishir! Thanks!!