How to validate email in odoo 9?plz send the code.
Welcome!
This community is for professionals and enthusiasts of our products and services.
Share and discuss the best content and new marketing ideas, build your professional profile and become a better marketer together.
Validate email
This question has been flagged
3
Replies
5400
Views
What context did you mean about "validate email in odoo 9"? Did you want to know about registration email validation?
no i mean email field validation in contacts details form.
Try the following code:
import re from openerp.exceptions import except_orm from openerp.tools.translate import _
Within the class, define the following method:
@api.one
@api.onchange('emai')
def validateEmail(selfl):
if self.email:
if re.match("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$", email) != None:
return True
else:
raise raise except_orm(_('Invalid Email'), _("Please enter a valid email address"))You also need to override create and write method to call the validateEmail method.