My regex works fine on regex101 and my regex is
[1-4]|(0)
But when I tried it on HTML input element's attribute it doesn't work as expected. My HTML is like below
<form action="/">
<input type="text" id="usernum" name="usernum" pattern="[1-4]|(0)" title="1-4 and must include at leat one 0">
<input type="submit">
</form>
I want users must enter one 0 along with the ranges digit.
|is for alternatives. So that matches either 1 through 4 or 0. It's the same as[0-4].[0-4]user can skip 0 but I want to force them to enter at least one 0|0would force a0?^(?=.*0)[0-4]+$