Validate negative and positive decimal numbers with RegEx

后端 未结 5 891
滥情空心
滥情空心 2020-12-09 23:39

I am trying to build a regex which will allow both negative and positive decimal numbers with the following rules.

  1. there can not be more than 2 digits after de
5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-10 00:02

    var NumberToValidate = 48428;
            var valid =  /^([0-9]*[1-9][0-9]*)$/.test(NumberToValidate);
            {
            if (!valid)
        alert("Invalid Quantity!!\nThe Quantity cannot be Zero\n or a part of a Unit !");
                return false;
            }
    

提交回复
热议问题