Date Range Validation with Alert (Within 2 weeks, 1 week, etc.)
Hello, novice here. I've attempted to pull information from two different solutions (credit try67 & johnk12695043 Validating Dates conversation). I assume I need the Today field to succeed, but if I don't, please let me know. I'm hoping I don't need it. Thank you for your attention!
Today Field is using a script :"this.getField("Today").value = util.printd("m/dd, ddd", new Date());"
My goal is to have two different alerts popup separately or simultaenously if it fulfills the following criteria: procedure date chosen is less than or equal to 2 weeks and 1 week from today's date. I'm using a Custom Date Text Field in the format of m/dd, ddd to give me (6/19, Fri format output). Was my attempt at this a complete fail?
Below is the validation script I attempted to run.
var sToday = this.getField("Today").value;
var sProcedure = this.getField("Procedure").value;
if(sToday.length && sProcedure.length) {
var dateToday = util.scand("m/dd, ddd",sToday);
var dateProcedure = util.scand("m/dd, ddd",sProcedure);
var nMilliResult = (sToday - sProcedure) * 1;
if (nMilliResult < 1209600000) {
app.alert("C19 Admin RN Order < 2 weeks");
event.rc = false;
if (nMilliResult < 604800000) {
app.alert("C19 Screening Questions < 1 week");
event.rc = false; }
}}

