When checking input using preg_match()
I am getting a match for invalid character in Firefox but not Chrome when user types in something like This comment
basically something with a space, but if they type in Thiscomment
and before submitting to server, and preg_match check
, they add a space between the words it will be fine.
Using pattern /^[a-zA-Z0-9 \s\.\-]*$/
and have tried with only and without \s and still no luck.
The content/text comes from a contentEditable
table cell managed by Angular.
php 5.6 firefox/chrome latest angular 1.5
A little more digging has shown that what is happening is firefox is inserting <br>
, basically <br>
, once in there deleting what has been added doesn't remove it. So I am experimenting with striping it out before running thru regex validation.
Ok, so more digging and realizing I will need to figure out how to manage this as chrome will also insert the characters when a new line is added to the text, like shift-return, which I want to support. Will just have to manage how to store, \n
or <br>
or <br>
AND manage when outputing to a text, alert, or table cell etc.
Thanks to everyone who took a look and commented. Sorry for the noise.
I'm gonna close this ticket now, or delete if I can't close, would like to not delete to save someone else time with this but not sure how to do this.