Copy link to clipboard
Copied
I have crated a form that employees use to move products to another department. On that field is the expiration date of the product. I want to crate a field that when the user puts in a previous date (i.e today is 5/19/16 and they put in 5/18/16) the field either turns red or a message box opens up indicating the product has expired. Thanks
You can use a custom Validate script for the text field, something like the following:
// Validate script for text field
(function () {
// Do nothing if the field is blank
if (!event.value) {
return;
}
// Get the current date/time
var oDate = new Date();
// Set the time of today's date to midnight
oDate.setHours(0, 0, 0, 0);
// Convert field entry to date object
// Use whatever date format the field is up for
var oDateEntered = util.scand("m/d/yyyy", event.valu
...Copy link to clipboard
Copied
You can use a custom Validate script for the text field, something like the following:
// Validate script for text field
(function () {
// Do nothing if the field is blank
if (!event.value) {
return;
}
// Get the current date/time
var oDate = new Date();
// Set the time of today's date to midnight
oDate.setHours(0, 0, 0, 0);
// Convert field entry to date object
// Use whatever date format the field is up for
var oDateEntered = util.scand("m/d/yyyy", event.value);
if (+oDateEntered < +oDate) {
// Alert the user
app.alert("Please enter a date that is not in the past.", 3);
// Optionally, reject the entry
event.rc = false;
}
})();
Copy link to clipboard
Copied
Thank you so much. It works great and doesn't get upset with a reset form button. Thank you so much.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now