Maybe the button dosen't have focus when the enter key is hit.

This added to your javascript may help

function check_email_onkeypress()
{
        if ("13" == window.event.keyCode) {
                form.submit();
        }
}

Also, I usually use the name attribute for the form. Like
<form method="post" action="2003springcontest.pl" name="f1" onSubmit="return
submitIt(this)">

If you do that, your elements need to be be preceeded with f1, so the code
block would be
function f1.check_email_onkeypress()
{
        if ("13" == window.event.keyCode) {
                f1.submit();
        }
}

Thanks a good practice because a page can have multiple forms.
Good Luck, bb



-----Original Message-----
From: Hughes, Andrew [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 01, 2003 10:31 AM
To: [EMAIL PROTECTED]
Subject: form user interface issue


I have a form that I am using to add data to a mysql database table.  I am
using a .pl scrtipt to generate the html.  I am using cgi.pm and param() to
insert the form data.  And, I am using to the print<<HTML;  function to
display my forms within the .pl script.  The problem is that when the user
completes the form and hits the enter key (as opposed to the mouse to submit
the form), the form goes blank and nothing happens.  However, if a user uses
the mouse, everything works fine.

Please let me know what you think the problem is.  Any assistance would be
greatly appreciated.

Thanks,
Andrew

Here's the code:

..snip1..

my $choice = lc(param("choice"));
my $check_email = WebDB::trim_and_collapse_whitespace
(lc(param("check_email")));

..snip1..

..snip2..
if ($choice eq "") {
        checkemailform(); # displays form
}
elsif ($choice eq "check") {
        checkemail(); # inserts the data
}

..snip2..

..snip3..

sub checkemailform {

print "Content-type:text/html\n\n";
print <<checkemailform;
<html>
<head>
<title>Insider's Advantage</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.main {font-family: Arial, Helvetica, sans-serif; font-size: 12px;
font-style: normal; font-weight: normal; color: #000000;}
.mainsmall {font-family: Arial, Helvetica, sans-serif; font-size: 10px;
color: #000000;}
.head {font-family: Arial, Helvetica, sans-serif; font-size: 14px;
font-weight: bold; color: #000000;}

-->
</style>

<SCRIPT LANGUAGE=JAVASCRIPT TYPE="TEXT/JAVASCRIPT">
function submitIt(form) {
                if (!validEmail(form.check_email.value)) {
                        alert("Invalid AOLTW Business E-Mail Address.")
                        form.check_email.focus()
                        form.check_email.select
                        return false
                }
}

function validEmail(check_email) {
                invalidChars = " /:,;"

                if (check_email =="") {
                        return false
                }
                for (i=0; i<invalidChars.length;
                        i++) {
                        badChar = invalidChars.charAt(i)
                        if (check_email.indexOf(badChar,0) >
                                -1) {
                                return false
                        }
                }
                atPos = check_email.indexOf("@",1)
                if (atPos == -1) {
                        return false
                }
                if (check_email.indexOf("@",atPos+1) >
                        -1) {
                        return false
                }
                periodPos = check_email.indexOf(".",atPos)
                if (periodPos == -1) {
                        return false
                }
                if (periodPos+3 > check_email.length)  {
                        return false
                }
                return true

} //end validEmail
</SCRIPT>

</head>

<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0"
marginwidth="0" marginheight="0">
<form method="post" action="2003springcontest.pl" onSubmit="return
submitIt(this)">
  <table width="500" border="0" align="center" cellpadding="2"
cellspacing="0">
    <tr>
      <td colspan="2" class="main" align="center"><img
src="http://insidersadvantage.com/images/promotions/2003brochure/signup_head
.jpg" border="0"></td>
    </tr>
    <tr>
      <td colspan="2" class="main">Please enter your work email address
below so that we may determine whether or not you are an E-Club member.
</td>
    </tr>
    <tr>
      <td colspan="2" class="main">* <i> <b>Indicates a required
field.</b></i></td>
    </tr>
    <tr>
      <td width="175" align="right" class="main">Work Email Address:</td>
      <td width="325" class="main"> <input type="text" name="check_email"
maxlength="60">
        *</td>
    </tr>
    <tr>
      <td colspan="2" align="center"><input type="submit" name="choice"
value="Check">
      </td>
    </tr>
    <tr>
      <td colspan="2" class="main">&nbsp;</td>
    </tr>
  </table>
</form>
</body>
</html>
checkemailform

}

..snip3..

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to