JS

JavaScript Demos:
E-mail Feedback Form.

jim.cerny@unh.edu   04-JAN-1998


your name:
 *

your e-mail address:
 *

your feedback:
 *

 *required items.


Discussion.

This example is EXACTLY THE SAME as previous example EXCEPT that instead of placing the JavaScript validation functions in the HEAD section of the HTML, it uses the "SRC" attribute on the "SCRIPT" tag to include an external ".js" file. In this case it is taken from the "/JS" public library that we maintain on the UNHINFO server. Anyone can use these library scripts, though we do not have additional online documentation for them. Similarly you can place ".js" files in the same directory where your HTML files reside, or you could create your own JavaScript library area within your Contributor Account. The UNHINFO server software supports the MIME-type "application/x-javascript" required for use of included ".js" files.


This is taken from Heinle, Chapter 4. It does a basic validation of each element of a form. It checks to make sure each field is not blank and in the case of the e-mail address it also makes sure it contains an at-sign and a period. Things start to get more complicated in the scripting.

Please note the following:

  • You can see what gets submitted on the form by looking at View -> Document Info in Netscape (3.x).
  • The successfully validated form in this example is submitted to a CGI script at an NCSA site that will echo back a copy of what you submitted; presumably you would replace that with a local CGI script when your testing was complete.