I want to ignore certain characters in my phone input, so that the database just has digits. I know I can do this easy on server side (using PHP) but I am trying to understa
I would strongly advise against changing the user's input or otherwise prevent them from typing something while they're doing it. It is confusing and leads to a bad user experience.
Ideally, you should keep your server-side validation and then use HTML5 features such as these:
Allows only numbers
Allows numbers, spaces, periods and hyphens
Specifies a required field
Modern browsers will prevent the form from being submitted and present helpful error message to the user (which you can customise with a title attribute).
However, for general reference, return false; doesn't necessarily cancel the event. To do that, you should use this:
// if you haven't already:
e = e || window.event;
// to cancel the event:
if( e.preventDefault) e.preventDefault();
return false;