My script is this:
var emailmask = /^[a-z0-9.]/g;
function restrictCharacters(myfield, e, restrictionType) {
if (!e) var e = window.event
if (e.keyCode) code = e.keyCode;
else if (e.which) code = e.which;
var character = String.fromCharCode(code);
if (code==27) { this.blur(); return false; }
if (!e.ctrlKey && code!=9 && code!=8 && code!=36 && code!=37 && code!=38 && (code!=39 || (code==39 && character=="'")) && code!=40) {
if (character.match(restrictionType)) {
return true;
} else {
return false;
}
}
}
The input:
<input type="text" name="fx_username" value="asd" id="username" class="normal email need" onkeypress="return restrictCharacters(this, event, emailmask);"/>
It simply does not work with IE, but FF, chrome is okay. Could you help me in this case please?
Edit: The does not work means, it does not stripped the special characters like @{}¤$ß.
Your function doesn’t always have a return-value.
If this condition :
doesn’t match, it will return nothing. Looks like the behaviour is different in browsers. In MSIE I think it’s somehow not evaluated to false.
Solution: add this at the end of the function: