I've an input which should allow numbers only. I tried adding <f:validateRegex>
as follows:
<f:validateRegex pattern="[0-9]" />
But I still get the error message,
Validation Error: Value not according to pattern '[0-9]'
How is this caused and how can I solve it?
The pattern [0-9]
allows input of a single digit only. Perhaps you want input of multiple digits? In that case, you should use a pattern of [0-9]+
. The +
modifier namely means "one or more".
<f:validateRegex pattern="[0-9]+" />
If you allow empty input, then use the *
modifier instead which means "zero or more".
<f:validateRegex pattern="[0-9]*" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With