一个输入框限定最多输入两位小数

一个输入框限定最多输入两位小数

 $(".m_text").bind("input propertychange",function(){  
    var reg = new RegExp("^\\d+(\\.\\d{0,2})?$");
    if(!reg.test($(this).val())){
        alert("请您输入正确的金额(只包含两位小数)");
        $(this).val("");
    }
})

猜你喜欢

转载自blog.csdn.net/zd717822023/article/details/76317918