S
shortbackandsides.no
I've been having trouble preventing users pressing Enter part way down
a form so the incomplete form gets submitted.
I came up with a possible solution - the code below seems to work in
both mozilla and MSIE - is this a good way to solve the problem? Is
there a better alternative? Have I done anything stupid?
My aim was to disable the normal submit process then use javascript to
submit which appears to bypass that and work...
Neither the normal submit button nor pressing Enter result in the form
being sent (so in a real world application one would use a button
rather than the normal submit field type).
<HTML><HEAD><TITLE></TITLE></HEAD><BODY >
<FORM ACTION="http://www.example.com/cgi-bin/myprogram.pl"
METHOD="POST" name="myform" onSubmit="return false;">
<input type="text" size="45" name="afield" value="a field" ><BR>
<INPUT type="reset" value="Reset">
<INPUT type="button" value="Submit (button)"
onClick="document.myform.submit();">
<INPUT type="submit" value="Submit (normal)" >
</FORM></BODY></HTML>
a form so the incomplete form gets submitted.
I came up with a possible solution - the code below seems to work in
both mozilla and MSIE - is this a good way to solve the problem? Is
there a better alternative? Have I done anything stupid?
My aim was to disable the normal submit process then use javascript to
submit which appears to bypass that and work...
Neither the normal submit button nor pressing Enter result in the form
being sent (so in a real world application one would use a button
rather than the normal submit field type).
<HTML><HEAD><TITLE></TITLE></HEAD><BODY >
<FORM ACTION="http://www.example.com/cgi-bin/myprogram.pl"
METHOD="POST" name="myform" onSubmit="return false;">
<input type="text" size="45" name="afield" value="a field" ><BR>
<INPUT type="reset" value="Reset">
<INPUT type="button" value="Submit (button)"
onClick="document.myform.submit();">
<INPUT type="submit" value="Submit (normal)" >
</FORM></BODY></HTML>