Date custom script

Hi, is there a script for the date that gets today’s date and cannot use past date and when they chose today’s date the date will automatically adds 2days when saved and if they chose tomorrows date it would only add 1 and if they chose the 3rd day it would not add anything.

frappe.ui.form.on(“Stock Request”, “validate”, function(frm) {
if (frm.doc.date_required < get_today()) {
msgprint(__(“Past dates are not allowed”));
validated = false;
}
});

you can use the following functions to achieve your functionality.

frappe.datetime.get_today()
frappe.datetime.get_day_diff("2016-05-05", "2016-05-03" )
frappe.datetime.add_days("2016-05-03", 2)
2 Likes

Hi, Here’s my script.
can you please tell me where can I put the function I want here?:

frappe.ui.form.on(“Stock Request”, “validate”, function(frm) {
if (frm.doc.date_required < get_today()) {
msgprint(__(“Past dates are not allowed”));
validated = false;
}
});