Forum Moderators: open
[b]HTML:[/b]
<textarea row="10" column="10" AUTOCOMPLETE="OFF" id="input_textbox01" onfocus="return passId(this);" value=''></textarea>
[b]Javascript:[/b]
function passId(oTextbox)
{
var inputbox=oTextbox;
inputbox.onkeydown= function (keyEvent)
{
oEvent= window.event || keyEvent;
oSource= oEvent.srcElement || oEvent.target;
//////////// should i deal this key press ?
iShouldDealIt=false;
var result=handleKeyboardInput(); // handleKeybaordInput function will change the value of iShouldDealIt if necessary
//alert(result);;
return result;
}
inputbox.onmousedown= function (keyEvent)
{
oEvent= window.event || keyEvent;
oSource= oEvent.srcElement || oEvent.target;
if( oEvent.button == 0)
{
updateRange(oEvent.rangeOffset); // update the mouse cursor position
}
return true;
}
inputbox.focus();
}
function handleKeyboardInput()
{
/*
-detect which key is pressed
If (the key belongs to the list that i wish to change) then
■ update source with the replacing value
■ return false so that browser doesn't write anything to the source text/textarea, i mean disable keydown event
else
return true; // Pressed key is not in my list, Let the browser normally in a keydown event.
*/
// skipped other or detail code
}