javascript and forms

by "Jim Stanford" <jrstanford(at)home.com>

 Date:  Tue, 18 Jan 2000 03:56:00 -0600
 To:  "hwg-languages" <hwg-languages(at)hwg.org>
  todo: View Thread, Original
I've been having a terrible time trying to make sense of creating a form
using input validation.  Below is a sample of the code (pardon the mess, I
could not get it to come over formatted).

I am sure the problem has to do with my not understanding how the DOM works,
but nothing I have read seems to be truly clear on this.  Any help is
appreciated.

Jim Stanford



<html>
 <head>
  <title>
   Form Testing Page
  </title>
<script language="javascript" type="text/javascript">

<!-- Hide script from older browsers

function checkForm(testform) {
    if (document.testform.name.value ="") {
        alert ("You must enter your name in the required field.")
        tmp.focus()
        tmp.select()
    }
}
 //  end hiding from older browsers -->

</script>

</head>
<body leftmargin="50">

<form name="testform" action="mailto:jrstanford(at)home.com" method="post"
onSubmit="checkForm(testform)">

<table cellpadding=2>
    <tr>
        <td></td>
        <td><font type="sans serif" size="5"><b>FORM TESTING</b></font></td>
    </tr>
    <tr>
        <td align="right">Name</td>
        <td><input type="text" size="40" name="name" value="">&nbsp; *</td>
    </tr>
    <tr>
        <td></td>
        <td><input type="submit" value="Submit" onClick>&nbsp;<input
type=reset></td>
    </tr>
</table>

</form>
</body>
</html>

HWG: hwg-languages mailing list archives, maintained by Webmasters @ IWA