I need some help because I have troubles with detection of accentuate characters.
I have an application (html, css, js) working on both PC and MAC. It contains some input fields with following properties :
- Text has to be numbers only
- It must contain only 8 characters (so 8 numbers)
- Each input is verified right away
Since the HTML input must contain a specific number of character I can't use the type="number"
, so it has the form : <input type="tel" maxlength="8"
My js function is the following one :
onChangeUserId: function (e) {
var theEvent = e.view.event;
var key = theEvent.keyCode || theEvent.which;
keyValue = String.fromCharCode(key);
var regex = /[0-9]{1,8}/;
if (key === 13) {
// validation function
} else if (!regex.test(keyValue)) {
theEvent.returnValue = false;
if (theEvent.preventDefault) theEvent.preventDefault();
}
},
My problem is that this is working on Windows, but OSx seems to allow the following characters (which are all accents) : ^ ¨ `
I didn't make this code, I "just" have to fix this bug actually, so maybe I am missing some things? But I have searched for a loooong time on the Internet, tried many things (especially on the regex, but this part seems to be just fine in the end) and couldn't manage to find why I have this problem and how I can solve it :/
If some of you have the answer, I would be happy to hear it (I'm kind of desperate now é_è)
Thank you :)
EDIT
As vove suggested it here, I followed this stack link which leads me to this JSFiddle Demo . This demo works fine with my PC, but with my mac, it allows the characters ^ ¨ `, so even this example does not work for me :/
Is anyone else having the problem?