I need to stop users from entering a colon or pipe on our web script, and I’ve used this piece of code:
}
function colonFilter(evt)
{
var e = event || evt;
var charCode = e.which || e.keyCode;
if (charCode == 58 || charCode == 124)
return false;
return true;
}
It works fine in Chrome, however, when I access the site in Firefox it doesn’t work. What did I do wrong?
You’re not passing the event object to the function. Chrome mimics Internet Explorer and maintains a global “event”; Firefox does not.
That’ll work in all browsers.