How to properly validate web form

I have created a webform i when write code for validation in corresponding python file i get error in chromes console window why is that

def validate(self):
validate_duplicate_contact_person(self.contact_details)
validate_email()

http://localhost:8003/ 417 (EXPECTATION FAILED)

frappe-web.min.js:1573 Traceback (most recent call last):
File “/home/shahid/meeting/frappe-bench/apps/frappe/frappe/app.py”, line 55, in application
response = frappe.handler.handle()
File “/home/shahid/meeting/frappe-bench/apps/frappe/frappe/handler.py”, line 19, in handle
execute_cmd(cmd)
File “/home/shahid/meeting/frappe-bench/apps/frappe/frappe/handler.py”, line 40, in execute_cmd
ret = frappe.call(method, **frappe.form_dict)
File “/home/shahid/meeting/frappe-bench/apps/frappe/frappe/init.py”, line 898, in call
return fn(*args, **newargs)
File “/home/shahid/meeting/frappe-bench/apps/frappe/frappe/website/doctype/web_form/web_form.py”, line 405, in accept
doc.insert(ignore_permissions = True)
File “/home/shahid/meeting/frappe-bench/apps/frappe/frappe/model/document.py”, line 189, in insert
self.run_before_save_methods()
File “/home/shahid/meeting/frappe-bench/apps/frappe/frappe/model/document.py”, line 750, in run_before_save_methods
self.run_method(“validate”)
File “/home/shahid/meeting/frappe-bench/apps/frappe/frappe/model/document.py”, line 651, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/shahid/meeting/frappe-bench/apps/frappe/frappe/model/document.py”, line 858, in composer
return composed(self, method, *args, **kwargs)
File “/home/shahid/meeting/frappe-bench/apps/frappe/frappe/model/document.py”, line 841, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/shahid/meeting/frappe-bench/apps/frappe/frappe/model/document.py”, line 645, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/shahid/meeting/frappe-bench/apps/erpnext/erpnext/schools/doctype/corporate_registration/corporate_registration.py”, line 13, in validate
validate_email()
File “/home/shahid/meeting/frappe-bench/apps/erpnext/erpnext/schools/doctype/corporate_registration/corporate_registration.py”, line 27, in validate_email
frappe.throw(_(“error”))
File “/home/shahid/meeting/frappe-bench/apps/frappe/frappe/init.py”, line 310, in throw
msgprint(msg, raise_exception=exc, title=title, indicator=‘red’)
File “/home/shahid/meeting/frappe-bench/apps/frappe/frappe/init.py”, line 303, in msgprint
_raise_exception()
File “/home/shahid/meeting/frappe-bench/apps/frappe/frappe/init.py”, line 276, in _raise_exception
raise raise_exception, encode(msg)
ValidationError: error

Hi, as I see your problem in the code erpnext/erpnext/schools/doctype/corporate_registration/corporate_registration.py", line 27, in validate_email frappe.throw(_("error"))
please check which code you have before 27 line.

@SwitsolAG i get error on while using frappe.throw()

but when i use frappe.msgprint() no error but form is submitting even validation is failed

@shahid_khan021,

can you share your code ?

Thanks

sorry, but honestly speaking as for me it works properly, why not? if you use throw it cannot be saved if you use msgprint it can be saved

@SwitsolAG

yes it is also happening for me but i got errror message in console of chrome at the end