Client script was not working for date validation?

Ramu6
Tera Contributor

Hi All,

Actually i have created client script for date validation , but  its not working on the form as expected

Please help me on this

Thanks

Ramu

Ramu6_0-1697121280771.png

 

 

8 REPLIES 8

Sagar Pagar
Tera Patron

Hi @Ramu6,

 

I would suggest to use the UI policies instead of Client scripts for date validations.

 

If my response helps you resolve your issue. Kindly mark it as helpful & correct. It will be helpful to future readers! 👍🏻
Thanks,
Sagar Pagar

The world works with ServiceNow

@Sagar Pagar 

thanks for the response

what would be the condition for that ui policy?

 

Hi @Ramu6,

 

You may add conditions as:

 

Deadline end date IS LESS THAN BEFORE Deadline start date

 

Execute if true:

function onCondition() {
g_form.clearValue("u_deadline_start_date");
g_form.showFieldMsg("u_deadline_start_date", "add error message" , "error");
}

 

If my response helps you resolve your issue. Kindly mark it as helpful & correct. It will be helpful to future readers! 👍🏻
Thanks,
Sagar Pagar

The world works with ServiceNow

Aman Kumar S
Kilo Patron

Hi @Ramu6 

 

Best way to achieve this would be using UI policy, as it will require less to no scripting.

First mark Run script as true then,

You can put alert and setting the value as empty in the if true condition script

 

I have shown how you can achieve it, you can do it the same way for your fields.

uipdate2.PNGuipdate.PNG

Best Regards
Aman Kumar