<input onkeyup="this.value=this.value.replace(/[^0-9-]+.[^0-9-]+/,‘‘);" id="retailPrice" type="text" class="layui-input" name="commodityDetails.retailPrice" required oninput="OnInputMath (event)" onpropertychange="OnPropChangedMath (event)" placeholder="请输入零售价" autocomplete="off" class="layui-input">
function OnInputMath (event) { layer.closeAll(); var reg=/^[1-9]\d*\.\d*|0\.\d*[1-9]\d*$/; //正整数 reg = /^[1-9]+[0-9]*]*$/ if(event.target.value==""||reg.test(event.target.value)==true){ } else { layer.msg("请输入数字 "); } }
原文地址:https://www.cnblogs.com/riyueqian/p/11559418.html
时间: 2024-11-16 03:51:12