JS regular limit can only input numbers or numbers with decimal points, and the number of digits after the decimal point is limited

JS regular limit can only input numbers or numbers with decimal points, and the number of digits after the decimal point is limited

 HaoOuBa
2021-02-23 / 2 Comments / 628 Reading / Checking whether to include
reminder:
This article was last updated on February 23, 2021, and has not been updated for more than 1311 days. If the content or picture is invalid, please leave a message for feedback.

Length represents the number of decimal places when entering decimal places

 const length = 2 const reg = new RegExp(`^\\d+(\\.\\d{1,${length}})?$`)
three

Comments (2)

cancel
  1.  head portrait
    grh
    Windows 7 · Google Chrome

    Empty package issuing, one single order website www.kuaid100.cn

    reply
  2.  head portrait
    have a look
    MacOS · Safari

     Draw

    reply