Disabled certain key to be entered using javascript

There is always the good way to prevent and verify the using enter data, especially for each text box or text area.


The following is script use the event object to check on the key code that the user enter, return false to prevent user to enter.


Disabled space to be enter in javascript

onKeypress=”if (event.keyCode == 32) event.returnValue = false;”


Sample:


Only allow number and . to be enter in javascript

onkeypress=”if (event.keyCode < 47 || event.keyCode /> 57) event.returnValue = false;”


Sample:

Leave a Reply

%d bloggers like this: