Try ERPNext Buy Support Partners Foundation

Web Forms validations

I am trying to add validations to a web form. But my function is not called on validate. The code present in the corresponding py file (in the web_form folder) is as below,

def validate(self):

What is the correct way to add server side scripts to a web form?

1 Like

Check this

you can use the same validate function of doctype for your webform
and validation rules will be applied on both

Just read this thread and I think the issue is still relevant.

  1. Sometimes we need to validate more strictly in the form. But can be more relax with doctype. Because form will be filled by public, and doctype can be corrected easier by system user.
    So doing validate in doctype (although work for both) sometimes is not the appropriate way to validate.

  2. The issue of not all script (server and client side) works on either places:

  • py for webform should be in py controller file for webform.
  • js script in js controller file should work as in Client Script (in doctype setup page).