Return to Snippet

Revision: 45089
at April 24, 2011 11:47 by frujo


Updated Code
$('#selector').keydown(function(event) {
				if ( event.keyCode == 46 || event.keyCode == 8 || event.keyCode > 112 ) {
				
				} 
				else {
					if (event.keyCode < 95) {
						if (event.keyCode < 49 || event.keyCode > 57 ) {
							event.preventDefault();
						}
					} 	
					else {
						if (event.keyCode < 97 || event.keyCode > 105 ) {
							event.preventDefault();
						}
					}	
				}
				
			});

Revision: 45088
at April 24, 2011 11:46 by frujo


Initial Code
$("#strPhone").keydown(function(event) {
if ( event.keyCode == 46 || event.keyCode == 8 ) {
} else {
if (event.keyCode < 95) {
if (event.keyCode < 48 || event.keyCode > 57 ) {
event.preventDefault();
}
} else {
if (event.keyCode < 96 || event.keyCode > 105 ) {
event.preventDefault();
}
}
}
});

Initial URL

                                

Initial Description

                                

Initial Title
Allow only digits, delete and backspace.

Initial Tags

                                

Initial Language
jQuery