I have two input fields that should only allow these characters to be submitted:
- Alpha characters
- Apostrophes
- Hyphens
- Whitespaces
I can add the first three to the pattern with no problems, however, when I include whitespaces, the pattern attribute does not work at all. Anything and everything will be accepted.
How can I include whitespaces into my pattern?
https://codepen.io/harlessmark/pen/BaZJYMa
<form>
<input
type="text"
placeholder="[a-zA-Z'-\s]+"
pattern="[a-zA-Z'-\s]+"
title="Only letters, hyphens, apostrophes, and spaces are permitted"
>
<button type="submit">
Submit
</button>
</form>