0👍
✅
I see two mistakes in your code:
- You forgot to specify that the pattern is a regex
- Your regex will basically match anything
I corrected the regex and added the correct javascript object:
data: function() {
return {
number: 12345,
pattern: new RegExp("^\d+$")
};
},
Codesandbox doesn’t let us escape \d
, so you can test with [0-9]+
instead of \d
in codesandbox.
I don’t know what input you want to allow exactly, but you can elaborate your regex using regex101.
Source:stackexchange.com