正则表达式
1、要求:只能输入0和非0开关的正整数
this.taskInfo.amount = (money.match(/^(0|[1-9][0-9]*)/g)[0]) || null /^(0|[1-9][0-9]*)/g)[0]
2、要求:保留一位小数,首位不能为0
this.taskInfo.money = (money.match(/^([1-9]*)(\.?\d{0,1})/g)[0]) || null /^([1-9]*)(\.?\d{0,1})/g)[0]
3、要求不能为零的正整数
this.taskInfo.fbday = (fbday.match(/^([1-9]*)/g)[0]) || null /^([1-9]*)/g)[0]
4、判断是否是数字的正则表达式
var numReg = /^[0-9]*$/ var numRe = new RegExp(numReg) if (!numRe.test(number)) { this.$message({ type: 'warning', message: '请输入数字 ', duration: 10000, showClose: true, }) return false }
更多web开发相关知识,请查阅 HTML中文网 !!