JavaScript: Restrict keyboard character input

This JavaScript restricts the character input the user can enter into an input or textarea. This is useful in aiding the user enter the correct information such as a number or username. You should also validate the input on the server-side why not read the article