Try ERPNext Buy Support Partners Foundation

Web Form Email Field Validation

I created the doctype and the web form with an email field which is Data type and in the option field i typed in it “Email” in order to use the default email validation but it is not working whatever the entered data is it get through and gets saved how can i solve this? thanks a lot in advance

1 Like

I am having the same issue. Here is the code I am using under client script of the webform:

frappe.web_form.validate = () => {
    if (!(frappe.utils.validate_type(frappe.web_form.get_value("email_address"), "email"))) {
        frappe.msgprint('Invalid email address');
        return false;
    }
}

After clicking on submit, the ‘Invalid email address’ message appears with the "Saved Successfully’ dialog box right behind it and the form is submitted with incorrect email address. I would like for the submission to not happen unless a valid email address is entered.

Any help would be appreciated.

frappe.throw is required to stop the process. msgprint will just print

Or you can simply put “Email” in Options for the email address field and it will be validated successfully.

cc: @kennethsequeira is the genius who taught me this today :clap:

The first issue posted by @Abdallah_Korraim is that he can not use the Email in Option to validate.

Use frappe.msgprint with raise_exception=True as one of the args will stop the saving of form just like frappe.throw.

It works smoothly in V13. I’d request you to upgrade and try again.