[SOLVED] Allow 18 years old or above in Date field

Hi guys

I need your help, please

what I want is to force a user to choose only date that is greater than 18 years in the “date field.”

For example, I set a field for a birthday date, so it’s not logical that user can choose “today” as its birthday date.

I hope someone can help me to code a script to achieve that.

thx in advance,

If you are using Custom Script, try the below snippet

    frappe.ui.form.on("doctype", "validate", function(frm) {
        if (frm.doc.birth_date > frappe.datetime.add_months(frappe.datetime.now_date(),-18*12)) {
            frappe.msgprint(__("You have to be at least 18 years old to proceed"));
            frappe.validated = false;

Thank you very much Mr. Manasan
It’s work perfectly, this is exactly what I was looking for :slight_smile:

Please accept my much appreciation for your awesome help.

One last question, if I need to make custom script like what you provide me, which language should I learn to be able to coding by myself?

The Custom Script is written in Javascript and you also need to understand some Frappe Framework Basics.

1 Like

Thank you, I will do my best to achieve that.

With Regards,