On Wed, 24 Aug 2005, Wes wrote:
[color=blue]
> Apparently some of our form users are trying to add new lines in a text
> field and are hitting the <enter> key thus causing the form to be submitted
> prematurely. There is no algorithm we can write that can determine that the
> user isn't actually finished filling out the form so the form just gets sent
> as is.[/color]
You might change it to a textarea.
[color=blue]
> The only solution I can think of is to catch the <enter> key[/color]
AFAIK, from the server side the only way to do that would involve sending
them some javascript, which in a www context some users will have disabled
for security reasons.
[color=blue]
> Just wondering if anyone else has had to solve this issue.[/color]
Detailed behaviour depends on the browser, but in the final analysis you
(as provider) can't always prevent an arbitrary user from submitting an
incomplete form, whether by accident or mischievously. If the situation
is critical, you could have two "submit" buttons with different name/value
pairs, noting that if Enter is used to submit a form when the focus is not
on either of them, typically the server will get sent the name/value pair
of the first one (or the name/value pair of neither of them), which you
can test for. So the first Submit button would be marked "Preview" and
the second one would be "Modify". You would only action the modification
if the server had seen the name/value pair of the Modify button in the
submission, otherwise you would re-display the proposed modification and
await further user action.
In less critical situations, perhaps no particular defence is needed,
other than asking users to verify their changes and re-modify them if they
weren't what was intended.