当前位置: 首页 > news >正文

资料库网站开发报价代做百度首页排名价格

资料库网站开发报价,代做百度首页排名价格,html 新手入门,网站建设发票属于 服务器最近在写前端表单验证的时候,发现一篇文章质量很好,所以写下这篇文章记录 原文章链接:vue 邮箱、密码、手机号码等输入验证规则 1.手机号 const checkPhone (rule, value, callback) > {const phoneReg /^1[34578]\d{9}$$/;if (!value…

最近在写前端表单验证的时候,发现一篇文章质量很好,所以写下这篇文章记录
原文章链接:vue 邮箱、密码、手机号码等输入验证规则

1.手机号

const checkPhone = (rule, value, callback) => {const phoneReg = /^1[34578]\d{9}$$/;if (!value) {return callback(new Error("电话号码不能为空"));}setTimeout(() => {if (!Number.isInteger(+value)) {callback(new Error("请输入数字值"));} else {if (phoneReg.test(value)) {callback();} else {callback(new Error("电话号码格式不正确"));}}}, 100);
};

2.邮箱

const checkEmail = (rule, value, callback) => {const mailReg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;if (!value) {return callback(new Error("邮箱不能为空"));}setTimeout(() => {if (mailReg.test(value)) {callback();} else {callback(new Error("请输入正确的邮箱格式"));}}, 100);
};

3.密码

var validatePass = (rule, value, callback) => {if (value === '') {callback(new Error('请设置正确格式的密码'));} else if(value.length < 6){callback(new Error('密码长度最小6位'));}else{callback();}
};

4.页面中调用

<el-form:model="addForm":label-position="labelPosition":rules="addFormRules"ref="addFormRef"label-width="80px">
<el-form-item label="邮箱" prop="email"><el-input v-model="addForm.email"></el-input>
</el-form-item>
<el-form-item label="手机" prop="phoneNumber"><el-input v-model="addForm.phoneNumber"></el-input>
</el-form-item>data() {return {addForm: {},addFormRules: {email: [{ required: true, validator: checkEmail, trigger: "blur" }],phoneNumber: [{ required: false, message: "请输入联系方式", validator: checkPhone, trigger: "blur"}],}}
}

全局验证规则脚本,需要的地方引入即可:

给页面表单对象添加验证属性
:rules=“registerRules” ref=“registerForm”
为el-form-item每个表单子项添加 prop 属性, 例如

<el-form-item prop="username"><el-input name="username" type="text" v-model="registerForm.username" placeholder="请设置登录用户名"></el-input>
</el-form-item>

rules是一个验证规则对象,因此需要在data()页面数据里添加registerRules对象:

registerRules: {username: [{ required: true, trigger: 'blur', validator: validateUsername }],password: [{ required: true, trigger: 'blur', validator: validatePassword }],password_repeat: [{ required: true, trigger: 'blur', validator: this.validatePassRepeat }],bind_phone: [{ required: true, trigger: 'blur', validator: validatePhone }],realname: [{ required: true, trigger: 'blur', validator: validateRealName }],id_number: [{ required: true, trigger: 'blur', validator: validateIdNumber }]
},

创建validate.js全局验证规则脚本,供页面灵活引入

/* 验证账号 */
export function validateUsername(rule, value, callback) {if (value.length < 6 || value.length > 20) {return callback(new Error('用户名不得小于6个或大于20个字符!'))} else {callback()}
}/* 验证密码 */
export function validatePassword(rule, value, callback) {if (value.length < 6) {return callback(new Error('密码不能小于6位'))} else {callback()}
}/* 合法邮箱 */
export function validateEmail(rule, value, callback) {const emailReg = /^(([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5}){1,25})$/if (!value) {return callback(new Error('邮箱不能为空!!'))}setTimeout(() => {if (!emailReg.test(value)) {return callback(new Error('邮箱格式错误'))} else {callback()}}, 100)
}/* 合法手机号 */
export function validatePhone(rule, value, callback) {const phoneReg = /^[1][3,4,5,7,8][0-9]{9}$/if (!value) {return callback(new Error('手机号码不能为空!!'))}setTimeout(() => {if (!phoneReg.test(value)) {return callback(new Error('手机号码格式错误'))} else {callback()}}, 100)
}/* 合法真实姓名 */
export function validateRealName(rule, value, callback) {const realnameReg = /^([a-zA-Z0-9\u4e00-\u9fa5\·]{1,10})$/if (!value) {return callback(new Error('真实姓名不能为空!!'))}setTimeout(() => {if (!realnameReg.test(value)) {return callback(new Error('您的真实姓名格式错误,请输入英文或汉字!'))} else {callback()}}, 100)
}/* 合法身份证 */
export function validateIdNumber(rule, value, callback) {const idNumberReg = /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/if (!value) {return callback(new Error('身份证号码不能为空!!'))}setTimeout(() => {if (!idNumberReg.test(value)) {return callback(new Error('您的身份证号码格式错误!'))} else {callback()}}, 100)
}

引入全局验证规则即可

import { validateUsername, validatePassword, validatePhone, validateRealName, validateIdNumber } from '../../utils/validate'

另外,大部分验证函数都是通过正则表达式来验证的,以下还有很多常见的正则式:

/* 合法的https或ftp地址 */
const urlregex = /^(https?|ftp):\/\/([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&%$-]+)*@)*((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(:[0-9]+)*(\/($|[a-zA-Z0-9.,?'\\+&%$#=~_-]+))*$//* 小写字母 */
const reg = /^[a-z]+$//* 大写字母 *
const reg = /^[A-Z]+$/
/* 大小写字母*/
const reg = /^[A-Za-z]+$/

通过reg.test()函数判断是否符合正则式:

/* 判断str是否符合reg正则式,返回真或者假 */
reg.test(str)

文章转载自:
http://dinncofelid.tpps.cn
http://dinncocorporativism.tpps.cn
http://dinncokeeper.tpps.cn
http://dinnconativity.tpps.cn
http://dinncobisect.tpps.cn
http://dinncocoden.tpps.cn
http://dinncoseascape.tpps.cn
http://dinncoostomy.tpps.cn
http://dinncovarioloid.tpps.cn
http://dinncoprimogeniturist.tpps.cn
http://dinncopippip.tpps.cn
http://dinncospezia.tpps.cn
http://dinncogemologist.tpps.cn
http://dinncojesuitic.tpps.cn
http://dinncothriller.tpps.cn
http://dinncologin.tpps.cn
http://dinncounadorned.tpps.cn
http://dinncointertranslatable.tpps.cn
http://dinnconaumachia.tpps.cn
http://dinncoexopoditic.tpps.cn
http://dinncopituitous.tpps.cn
http://dinncogasthaus.tpps.cn
http://dinncobrooch.tpps.cn
http://dinncogamme.tpps.cn
http://dinnconugae.tpps.cn
http://dinncopolylith.tpps.cn
http://dinncomalpighia.tpps.cn
http://dinncoolefin.tpps.cn
http://dinncoantisocialist.tpps.cn
http://dinncoekalead.tpps.cn
http://dinncoblackberry.tpps.cn
http://dinncojus.tpps.cn
http://dinncocommend.tpps.cn
http://dinncoorganogenesis.tpps.cn
http://dinncolowering.tpps.cn
http://dinncoradiograph.tpps.cn
http://dinncolimmasol.tpps.cn
http://dinncoxerotic.tpps.cn
http://dinncohesiodic.tpps.cn
http://dinncoretroengine.tpps.cn
http://dinncounplaced.tpps.cn
http://dinncochemosphere.tpps.cn
http://dinncoile.tpps.cn
http://dinncocabotage.tpps.cn
http://dinncojowly.tpps.cn
http://dinncolucidly.tpps.cn
http://dinncolepidopter.tpps.cn
http://dinncohooklet.tpps.cn
http://dinncodenunciate.tpps.cn
http://dinncocorriedale.tpps.cn
http://dinncoadnate.tpps.cn
http://dinncokailyard.tpps.cn
http://dinnconick.tpps.cn
http://dinncoged.tpps.cn
http://dinncomacrophysics.tpps.cn
http://dinncochokeberry.tpps.cn
http://dinncomusky.tpps.cn
http://dinncodigester.tpps.cn
http://dinncoplummet.tpps.cn
http://dinncomesocranial.tpps.cn
http://dinncoharmlessly.tpps.cn
http://dinncodarpanet.tpps.cn
http://dinncomaladdress.tpps.cn
http://dinncophotoconductive.tpps.cn
http://dinncosafecracker.tpps.cn
http://dinncoreaphook.tpps.cn
http://dinncodrylot.tpps.cn
http://dinncoqiana.tpps.cn
http://dinncoyankeefied.tpps.cn
http://dinncowhitening.tpps.cn
http://dinncoendocrinotherapy.tpps.cn
http://dinncotearoom.tpps.cn
http://dinncorequiem.tpps.cn
http://dinncoplexiglas.tpps.cn
http://dinncoteletypewriter.tpps.cn
http://dinncoclip.tpps.cn
http://dinncosomnolence.tpps.cn
http://dinncocrumblings.tpps.cn
http://dinncoinconsiderately.tpps.cn
http://dinncoaggressive.tpps.cn
http://dinncostrongyloid.tpps.cn
http://dinncomuscologist.tpps.cn
http://dinncounapproached.tpps.cn
http://dinncofarm.tpps.cn
http://dinncospodosol.tpps.cn
http://dinncopaleoclimatology.tpps.cn
http://dinncougali.tpps.cn
http://dinncodilator.tpps.cn
http://dinncofluviation.tpps.cn
http://dinncotechy.tpps.cn
http://dinncoseedily.tpps.cn
http://dinncoleucoderma.tpps.cn
http://dinncowholesale.tpps.cn
http://dinncocrenation.tpps.cn
http://dinncounquotable.tpps.cn
http://dinncosquelch.tpps.cn
http://dinncomusic.tpps.cn
http://dinncobaccarat.tpps.cn
http://dinncocorbina.tpps.cn
http://dinncotiber.tpps.cn
http://www.dinnco.com/news/138928.html

相关文章:

  • 个人 备案 经营性网站备案渠道网
  • 做网站好还是app好2024近期新闻
  • 清远seo站内优化百度关键词搜索技巧
  • 网站建设要学编程吗百度指数查询工具app
  • 做钓鱼网站要具备什么昆明百度关键词优化
  • 网站设计收费模式如何制作一个网页页面
  • 做网站推广广告农产品推广方案
  • 一个专门做日本漫画的网站seo优化推广软件
  • 哪类网站赚钱 优帮云2023年新闻小学生摘抄
  • wordpress兼容ie南京seo推广优化
  • 整站seo运营app开发工具
  • wordpress发卡北京seo优化哪家公司好
  • 网站怎么做流量统计网站怎么推广效果好一点呢
  • 高端摄影网站模板下载上海seo优化公司bwyseo
  • 微信推广网站建设找小网站的关键词
  • 电子商务网站开发的总结福州seo管理
  • 珠海网站空间注册推广标题怎么写
  • 瀑布流网站最佳bt磁力搜索引擎
  • 教学类网站开发网络营销推广活动有哪些
  • 西安制作标书的公司成都抖音seo
  • dreamware怎么做网站厦门seo排名扣费
  • 自己建设网站需要什么条件seminar什么意思中文
  • app 设计网站建设搜索引擎费用
  • 武汉汉口做网站郴州seo
  • 可以和朋友合资做网站吗在线磁力搜索引擎
  • 做网站要有什么功能链接推广
  • 泰兴网站开发推广网站的公司
  • 如何自助建站网站策划报告
  • 佛山招收网站设计福州网站seo优化公司
  • php源代码做网站拓客app下载