Greetings to all,

I've a question regarding the reading of form submission. The html form in question is as follows:

<form name="myform" action="lgoin.pl" method="post"> <table <tr><th align="center" colspan="2">Login</th> <tr><td>Password</td><td><input type="text" name="pwd" size="5"> +</td></tr> <tr><td align="center" colspan="2"><input type="submit" name="lo +gin" value="doit"></td></tr> </table> </form> # portions of cgi code my $doit = param('login'); my %functions = ('login' => \&do_login, 'logout' => \&do_logout, ); if defined($doit) { &{ $functions{$doit} }; } else { default_page(); }
If the user clicks on the submit button 'doit', the submission is registered as desired. The value of the pwd field value is processed in the login sub.

However, if instead of clicking on the submit button, the user hits Enter after he has entered a value in the password field and while the cursor is still in the field, the form submission is not detected correctly.

How do you ensure that whether it's the button or Enter that is hit, the form submission is processed correctly?

I hope I've described what I'm trying to achieve in as clear a manner as possible.

I look forward to your enlightenment :)


In reply to Form submit detection... by kiat

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.