Hi guys,
I was wondering how do I enable the Backspace key, and the arrow keys on the keyboard so the user can scroll and fix their mistakes.
Currently I am using this to only allow users to enter a specific alphabet characters inside the textarea:
and
this is my recall for the script in the textarea:
I was wondering how do I enable the Backspace key, and the arrow keys on the keyboard so the user can scroll and fix their mistakes.
Currently I am using this to only allow users to enter a specific alphabet characters inside the textarea:
Code:
<script type="text/javascript">
var allow_backspace = true;
var arrValidChars=new Array("A", "C", "G", "N", "T", "a", "c", "g", "n", "t");
var arrSpecialChars = new Array(0, 2, 6, 13, 19, 26, 28, 32, 39, 45);
function VerifyCharacters(event, objInput) {
var strText = objInput.value;
var keyCode = event.keyCode||event.charCode;
if (InArray(arrSpecialChars, keyCode) >= 0)
return true;
var strChar = String.fromCharCode(keyCode);
return (InArray(arrValidChars, strChar)>=0);
}
function InArray(arr, key) {
for (var i=0; i<arr.length; i++) {
if (arr[i] == key)
return i;
}
return -1;
}
</script>
and
this is my recall for the script in the textarea:
Code:
<textarea name="Sequence" cols="60" rows = "10" onkeypress= "return VerifyCharacters(event, this)"> </textarea>