Skip to main content
Inspiring
February 26, 2019
Answered

validate

  • February 26, 2019
  • 1 reply
  • 478 views

I am attaching an image of a portion of a log page. As you see, there are multiple (six) identical records - each has a date field.

I need to do two things: 1) Assure that the date being entered does not predate the date field in the previous record, and 2)

verify that there is indeed a date in the date field of the previous record (avoid skipping records). Here is some code I have tried, but I cannot get the if condition to work:

Please share your thoughts.

//THIS VALIDATES THE DATE ENTERED

var cMsg = "The date you entered is invalid.\n\nPlease enter a date that does not pre-date the previous entry date.";

var nIcon = 0;

var nType = 0;

var cTitle = "DATE ERROR";

var str = event.target.name;

var res = str.charAt(str.length-1);

var d1 = Date.parse(this.getField("0." + (res-1)).value);

var d2 = Date.parse(event.value);

if (d1 == 0) {

if (d1 > d2) {

app.beep();

app.alert(cMsg, nIcon, nType, cTitle);

event.value = "";

}

} else {

var cMsg = "This is an invalid entry\n\nThe previous date entry cannot be empty.\n\nPlease use the entry above first.";

app.beep();

app.alert(cMsg, nIcon, nType, cTitle);

}

This topic has been closed for replies.
Correct answer try67

Duplicate of: CONFIRM SEQUENTIAL DATE ENTRIES

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
February 26, 2019