Forum Moderators: open
ideally, if should be:
<script type="text/javascript"><!--
function entertag(evt){
evt=(evt)?evt:event;
charCode=(evt.which)?evt.which:evt.keyCode;
if(charCode==13)document.form.submit();
}
//--></script>
<textarea onkeypress="entertag(event)" name=message></textarea>
but my problem here is, under my situation, i'm not allowed to insert onkeypress="entertag(event)" into the textarea tag.
Does anybody know how to attach that function into the onkeypress event of the textarea?
something like:
document.forms.message.onkeypress = entertag(event)
but the above wouldn't work. Please help here!
here is the code:
<script type="text/javascript"><!--
function entertag(evt){
evt=(evt)?evt:event;
charCode=(evt.which)?evt.which:evt.keyCode;
if(charCode==13)document.form.submit();
}
window.onload=attach;
function attach(){
document.forms.message.onkeypress = entertag;
}
//--></script>