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(); }">

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.

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.

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.

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.

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.