Skip to Content
Menu
This question has been flagged
2 Replies
12481 Views

How to validate email entered in odoo10?

Avatar
Discard

Wrong question asked, this question is not related to odoo, this is python related question. you may find the answer for this question on stack overflow. there are many examples available for this question on stack overflow. Please ask only odoo related question here, otherwise your question would be downgraded.

Best Answer

Hi , you can use below code to validate email Id:-

import re
from odoo.exceptions import ValidationError

@api.onchange('email_id')
def validate_mail(self):
if self.email_id:
match = re.match('^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$', self.email_id)
if match == None:
raise ValidationError('Not a valid E-mail ID')
Avatar
Discard
Best Answer

Working thanks

Avatar
Discard