Start Date cannot be in future - Client Script

Sadhana
Giga Contributor

Hi Experts,

Is there any way to validate start date to ensure it is not in future on client side, i don't want to make a GlideAjax Call for this?

TIA

1 ACCEPTED SOLUTION

Anurag Tripathi
Mega Patron
Mega Patron

Hi,
You can use a ui policy with condition as shown below:

find_real_file.png


In the script part you just have to throw the error on the start date like below:
g_form.setValue('start_date', '');
g_form.showFieldMsg('start_date','Start Date cannot be in future','error');

 

PS: Make sure you have the same field name as I have used.


-Anurag

-Anurag

View solution in original post

3 REPLIES 3

Anurag Tripathi
Mega Patron
Mega Patron

Hi,
You can use a ui policy with condition as shown below:

find_real_file.png


In the script part you just have to throw the error on the start date like below:
g_form.setValue('start_date', '');
g_form.showFieldMsg('start_date','Start Date cannot be in future','error');

 

PS: Make sure you have the same field name as I have used.


-Anurag

-Anurag

Hey Anurag,

I wanted to let you know that this method doesn't work on a custom workspace.

 

Thanks,

Gonzalo

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Why client script? Why not no code?

Have a look at this article I wrote a while ago:
No Code date validations thru (Catalog) UI Policies

Again, no code.

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn