Entry
Is it possbile to filter user input in text area to prevent or trap certain characters?
Aug 11th, 2006 15:20
David Alden, Javascript User,
<html>
<script type="text/javascript" language="javascript">
function filterUserInput(event){
// keyCode for the SHIFT key is 16, for ENTER key is 13
// this function basically doesn't allow the ENTER key
to be pressed inside the TextArea
// thus filtering out a certain key
if(event.keyCode==13){
return false;
}
}
/*
// this function tells you what key you are pressing, uncomment to use
document.onkeydown = function (evt) {
alert(evt.which);
alert(evt.keyCode);
alert(evt.charCode);
}
*/
</script>
<form name="thisForm">
<textarea onkeydown="return filterUserInput(event)"
name="thisTextarea"></textarea>
</form>
</html>