跳至内容
菜单
此问题已终结
2 回复
7296 查看

how to achieve email validation in openerp 7.0 and what is the use of widget="email"

形象
丢弃
最佳答案

In .py file write this method..........

import re

def  ValidateEmail(self, cr, uid, ids, email):
        if re.match("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$", email) != None:
            return True
        else:
            raise osv.except_osv('Invalid Email', 'Please enter a valid email address')

In view.xml file write this line

<field name="email" on_change="ValidateEmail(email)"/>
形象
丢弃
最佳答案

@ Akki Modi

You should add a condition when the field email is empty, because onchange methods are executed even during a record creation, so when it find it null, because you have not filled values yet, the onchange method will return an error !

形象
丢弃
相关帖文 回复 查看 活动
0
8月 19
2613
4
7月 20
5998
1
7月 25
1058
5
5月 25
18500
0
4月 25
1214