正则判断输入数字

//input只能输入正整数,直接在input标签写的
	onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')"
	
//input只能输入数字
	let numm = this.params.readjust_price;
	let myreg = /^([0-9]{1,}[.][0-9]*)$/;
	let myreg2 = /^([0-9]{1,})$/;
	if(!myreg.test(numm) && !myreg2.test(numm)){
		this.params.readjust_price = '';
		this.$layer.msg('请输入数字');
	}
发布了47 篇原创文章 · 获赞 4 · 访问量 6690

猜你喜欢

转载自blog.csdn.net/lifangfang0607/article/details/100539623