[Solved] Issue submitting a textarea by pressing enter [duplicate]


You can do this quite simply by adding a keypress event handler to the textarea:

<form id="form1">
    <div>
        Comment:
    </div>
    <div>
        <textarea onkeypress="if(event.which==13)document.getElementById('form1').submit();"
            placeholder="Make your comment..."
            name="textarea" form="form1" maxlength="200" id="textarea"></textarea>
        <input style="visibility:hidden" type="submit" form="form1" name="submitForm" id="submitForm" value="Submit"> 
    </div>
</form>

That checks if the pressed key has keycode 13 (which is the keycode for the enter key), and submits the form if it does.

9

solved Issue submitting a textarea by pressing enter [duplicate]