1. 判断输入是否是数字
var numReg = /^[0-9]+$/
var numRe = new RegExp(numReg)
if (!numRe.test(number)) {
this.$message({
type: 'warning',
message: '请输入数字 ',
duration: 10000,
showClose: true,
})
return false
}
本文介绍了一种使用正则表达式验证输入是否为纯数字的方法,通过创建正则表达式对象并使用test方法检查字符串是否符合指定的数字模式。
var numReg = /^[0-9]+$/
var numRe = new RegExp(numReg)
if (!numRe.test(number)) {
this.$message({
type: 'warning',
message: '请输入数字 ',
duration: 10000,
showClose: true,
})
return false
}
转载于:https://www.cnblogs.com/shix0909/p/11179885.html
1264
3379
545
1856

被折叠的 条评论
为什么被折叠?