kavinkuan

input 输入的一些限制说明

input输入框 只能输入 数字可以有小数点

<input class="form_text" id="purchasePrice" name="purchasePrice" value="" onkeyup="value=value.replace(/[^\d.]/g,\'\')"
dataType="/^-?[1-9]+(\.\d+)?$|^-?0(\.\d+)?$|^-?[1-9]+[0-9]*(\.\d+)?$/" errormsg="必须为数字,可以有小数" msg="此项为必填" />

或者写成

<input class="form_text" id="purchasePrice" name="purchasePrice" value="" onkeyup="checkValue(this)"
dataType="/^-?[1-9]+(\.\d+)?$|^-?0(\.\d+)?$|^-?[1-9]+[0-9]*(\.\d+)?$/" errormsg="必须为数字,可以有小数" msg="此项为必填" />

function checkValue(obj)
{
  var objVal = $(obj).val();
  $(obj).val(objVal.replace(/[^\d.]/g,\'\'));
}

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-12-08
  • 2022-12-23
  • 2021-12-13
  • 2021-09-10
  • 2022-12-23
  • 2022-12-23
  • 2021-11-28
猜你喜欢
  • 2021-07-24
  • 2021-05-17
  • 2022-12-23
  • 2022-02-15
  • 2022-01-14
  • 2022-12-23
相关资源
相似解决方案