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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.