jquery only allow input float number

前端 未结 13 1729
既然无缘
既然无缘 2020-12-01 06:28

i\'m making some input mask that allows only float number. But current problem is I can\'t check if multiple dots entered. Can you check those dots and prevent it for me?

13条回答
  •  猫巷女王i
    2020-12-01 07:07

    I found this way to do this,

    $.validator.addMethod("currency", function (value, element) {
      return this.optional(element) || /^\$(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$/.test(value);
    }, "Please specify a valid amount");
    

    https://gist.github.com/jonkemp/9094324

提交回复
热议问题