Jump to content

submit form on enter button


TeddyKiller

Recommended Posts

Considering the enter key only does new lines and doesn't submit the form. Quite impossible.

 

You'll need to tab out of whatever box your typing in obviously.

 

Well yeah, but how would you do it just by clicking enter? I've tried all methods and they dont actually work.

 

Attach a JavaScript keydown event, if the key is enter submit the form. This isn't possible with PHP as it is client side.

 

Again, I've tried many methods.. this is what I've got at the moment.

<script type="text/javascript">
<!--
function submitenter(myfield,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;
if (keycode == 13)
{
document.form.submit();
return false;
}
else
return true;
}
//-->
</script>

<form>
    <textarea name="nonaction" cols="50" rows="3" wrap="virtual" id="rptext" class="textarea" onKeyPress="return submitenter(this,event)"></textarea>
      <input type=submit value=SUBMIT>
</form>

 

Thoguh it doesn't work, though yes. It is a text area.

Considering the enter key only does new lines and doesn't submit the form. Quite impossible.

 

Oh and I just noticed, this is the wrong place for this post >.< Sorry

 

I realised, it's put in that post >.<

Should I repost?

 

No, double posting is NOT allowed. Your thread has been moved (twice) and is now in the correct location.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.