Future DOB not allowed and clear the value

vikramA
Kilo Contributor
 
3 REPLIES 3

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @vikramA 

 

Here is same of future date, make changes and you will be ready.

 

https://www.servicenow.com/community/virtual-agent-forum/gt-planned-start-date-gt-should-be-in-futur...

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Ankur Bawiskar
Tera Patron
Tera Patron

@vikramA 

you can use onChange client script for this

something like this

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }

    var today = new Date().getTime();
    var selectedDate = new Date(newValue).getTime();

    if (today < selectedDate) {
        alert('You cannot select future date');
        g_form.clearValue('selected_date');
    }
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Juhi Poddar
Kilo Patron

Hello @vikramA 

You can meet this requirement by configuring UI policy:

Please refer the screenshots below:

UI policy:

JuhiPoddar_0-1746336866492.png

UI policy action:

JuhiPoddar_2-1746337247484.png

Result:

JuhiPoddar_4-1746337347066.png

JuhiPoddar_3-1746337309653.png

Note: This approach allows you to achieve the requirement through configuration alone, with no scripting required.

Hope this helps!

 

"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"

 

Thank You
Juhi Poddar