How to validate a text field so it can only contain a four digit number

前端 未结 2 1326
失恋的感觉
失恋的感觉 2021-01-15 12:03

I\'ve managed to validate my field so it is always four digits, but i need to validate so that it is always a number. I tried adding this block of code but it doesn\'t work

2条回答
  •  深忆病人
    2021-01-15 12:33

    /^[0-9]{4}$/ for four numbers

    /^[0-9]*$/ for any amount of numbers

    /^[0-9]+$/ for at least one number

提交回复
热议问题