Vue-邮箱正则验证
http://www.manongjc.com/detail/6-tnjbwpjylrgxymd.html
Vue-邮箱正则验证
时间:2019-06-12
本文章向大家介绍Vue-邮箱正则验证,主要包括Vue-邮箱正则验证使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。
<el-form ref="emailForm" :model="emailForm" :rules="rules" label-width="120px"> <el-form-item label="电子邮箱" prop="mailAddress"> <el-input placeholder="请填写邮箱地址" v-model="emailForm.mailAddress" @blur="sendEmail"></el-input> </el-form-item> </el-form>
export default { name: 'email', data() { return { emailForm: { mailAddress: null }, rules: { mailAddress: [{ required: true, message: '请填写电子邮箱', trigger: 'change' }] } } }, methods: { sendEmail: function() { var regEmail = /^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/ if (this.emailForm.mailAddress != '' && !regEmail.test(this.emailForm.mailAddress)) { this.$message({ message: '邮箱格式不正确', type: 'error' }) this.emailForm.mailAddress = '' } } } }
原文地址:https://www.cnblogs.com/zltao/p/11007950.html