For some reason I'm having problems making this work with HTML5 form validation pattern attribute. I'm trying to match this condition /[!?^$\\\/{}]/g
. I have tried escaping \
removing the \
with the global attribute, removing the []
, almost everything. So there's always a first time to post a question on stackoverflow.
In a nutshell the user shouldn't input the following \/${}
<form action="#">
<input type="text" required pattern="/[!?^$\\\/{}]/g">
<button type="submit">Submit</button>
</form>
4.20 - 4.21 New export
-> Should be valid
4/20 - 2/21 $New {export}
-> Should be invalid
Here's the fiddle: http://jsfiddle.net/TV28A/