I am creating a form in html and for a text input, I want to have a regex validation on it that only allows the user to input: letters of the alphabet, numbers and certain characters;
/ - forward slash
- - hyphen
. - period (full stop)
& - ampersand
- spaces
I have tried this pattern but to no avail:
[a-zA-Z0-9\/\-\.\&\ ]
My HTML code:
<input type="text" id="payment_reference" name="payment_reference" maxlength="18" value="' . $payment_reference_default . '" pattern="[a-zA-Z0-9\/\-\.\&\ ]" required>
I know how to get only alphabet characters and numbers, but allowing the other characters as well is something I'm unable to manage.