I am having this issue where I want an INPUT field to be just NUMBERS or EMPTY.
If a user chooses to add a phone number or leave it blank if they don’t want to.
I tried using this, but it requires a phone number if it’s empty:
"onlyNumberSp": {
"regex": /^[0-9\ ]+$/,
"alertText": "* Numbers only"
},
Thank you
/^[0-9]*$/allows any amount of digits, including none at all (= empty string).In case you want to keep whitespace allowed, use
/^[0-9 ]*$/(no need to escape the space character).