Planned start date must be after current date

Black Coder
Tera Guru

In the change request I have to validate the Planned start date that it should be after the current date. I was able to create the Field level error message whenever the planned start date is earlier than the current date. But regardless of that field-level error, when a user submits the form, the wrong value is getting updated.

How can we prevent the user from submitting a form if the planned start date is selected with earliar date

 

14 REPLIES 14

Black Coder
Tera Guru

@Ankur Bawiskar There is an out of validation for Plan start sate and Plan end date which is "Planned end date must be after Planned start date". Similar to that I need to make validation for the Planned start date and current date. So it should show the same kind of error in my validation

 

Hi,

your updated onSubmit client script

function onSubmit(){

var selectedDate = new Date(g_form.getValue('start_date'));

var todayDate = new Date(); // Now

if (selectedDate.getTime() < todayDate.getTime()) {

alert("Planned start date must be after current date");
return false;

}

}

Regards
Ankur

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

@Black Coder

Hope you are doing good.

Did my reply answer your question?

If so, please mark appropriate response as correct & helpful so that the question will appear as resolved for others who may have a similar question in the future.

Thanks!
Ankur

 

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

@Black Coder

Hope you are doing good.

Did my reply answer your question?

If so, please mark appropriate response as correct & helpful so that the question will appear as resolved for others who may have a similar question in the future.

Thanks!
Ankur

 

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

@Black Coder

Hope you are doing good.

Did my reply answer your question?

If so, please mark appropriate response as correct & helpful so that the question will appear as resolved for others who may have a similar question in the future.

Thanks!
Ankur

 

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