Jump to content

submit form with return key


dhimok

Recommended Posts

Im on IE7 and i can submit forms with return. Anyway u can try this simple javascript to catch if the return key is pressed. I made it for a textarea to test it correctly.

 

<textarea name="textfield" onkeypress="if(window.event.keyCode == 13){ form1.submit(); }">

Link to comment
Share on other sites

BUT not if you use <button or <input type="button".

 

both of those are invalid for most buttons.

 

If you want to do buttons that accept return you can always add a tab code to it.

 

<input type="submit" value="submit" name="submit" acesskey="13">

 

You dont need acesskey, I just use it for acessability with program that people may use to show websites.

Link to comment
Share on other sites

I read that IE doesn't set the submit value when submitted with the return/enter key rather than the submit button. So it's more of an issue of handling the submission.

When checking input, I check for the actual input fields, not the submit value.

On a couple pages that have multiple forms, I will sometimes have a hidden field that I set and check for.

Link to comment
Share on other sites

I read that IE doesn't set the submit value when submitted with the return/enter key rather than the submit button. So it's more of an issue of handling the submission.

When checking input, I check for the actual input fields, not the submit value.

On a couple pages that have multiple forms, I will sometimes have a hidden field that I set and check for.

 

Its true. Submit value will pass to post or get only if one presses it with mouse. I either check for input fields instead of submit.

Link to comment
Share on other sites

the funny part is it ONLY does this if you give the submit button the "name" field or the "value" field.

 

A submit button BAREBONE IS:

 

<input type="submit">

 

this will show a standard button that says submit (and old browsers show a nice clickable rectangle with no text in it)

 

only if you have name="submit" or value="submit" will it pass ?submit or ?submit=submit to a POST or GET var.  I tried foreach on post to benchtest these and I got it says submit as a result only when name and value are given.

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.