RE: PDF Form and Date Validation
Hello,
I am currently processing a Date control/field on a PDF form, and I want to test if a value (entered via the Date Control field/ or manually typed) is NOT the format of dd/mm/yyyy and or is greater than Today's date, how can I test for that?
Below is the custom validation script I have written so far...
The 'greater than' part works - if (formatDate.setHours(0,0,0,0) >= todaysDate.setHours(0,0,0,0)), but how can I test for a value that is entered as mm/dd/yyyy or just a text value such as 'Test'. Both of these entries would be incorrect. I have tried with - else if (dateParse <= 0), and that does not work.
// Current Date Field
if (event.value != ""){
var todaysDate = new Date();
var formatDate = util.scand("dd/mm/yyyy", event.value);
var dateParse = Date.parse(event.value);
if (formatDate.setHours(0,0,0,0) >= todaysDate.setHours(0,0,0,0)) {
app.alert("Invalid date format entered -- please enter in DD/MM/YYYY format, \n\nfor example, 18/05/1999)", 2, 1, " Please check date entered");
event.value = "";
} else if (dateParse <= 0) {
app.alert("Invalid date entered -- please enter in DD/MM/YYYY format, \n\nfor example, 18/05/1999)", 2, 1, " Please check date entered");
event.value = "";
}
}
