Back to 10/96 Features: Form-id able Function
Up to Table of Contents
Ahead to 10/96 Features: Form-id able Function

10/96 Features: Form-id able Function

JavaScript Forms

Click Here to see a 30.0 KB bitmap image of artwork which goes with this article, entitled:
JavaScript

The results are in: It's JavaScript by a landslide in the scripting-language war.

JavaScript, which is trademarked by Sun Microsystems and licensed to third parties by both Sun and Netscape, is currently supported in both Netscape Navigator and Microsoft Internet Explorer. It places the burden of the Internet where it belongs: on the user's machine. JavaScript doesn't take up bandwidth or server CPU time; it runs, in real time, inside standard HTML code.

This sample script shows you how JavaScript can locally validate passwords. The correct password is "8444" and when you type it in correctly, JavaScript returns the alert "Your Password Passes! Continue at Your Own Risk!" If you enter the password incorrectly, JavaScript alerts you with "Password Does Not Pass Parsing! Access Denied!" You can copy and paste this piece of JavaScript into your HTML code. Netscape Navigator and Microsoft Internet Explorer will be able to read it and process the password validation scheme.

<HTML>

<HEAD>

<TITLE>Valid Form Input Test</TITLE>

<SCRIPT LANGUAGE="JavaScript">

function testResults (form) {

TestVar = isNumberString (form.inputbox.value)

if (TestVar == 1)

alert ("Your Password Passes! Con-

tinue at Your Own Risk!");

else

alert ("Password Does Not Pass Parsing! Access Denied!");

}

function isNumberString (InString) {

if(InString.length==0) return (false);

var RefString="8444";

for (Count=0; Count < InString.length;

Count++) {

TempChar= InString.substring (Count,

Count+1);

if (RefString.indexOf (TempChar,

0)==-1)

return (false);

}

return (true);

}

</SCRIPT>

</HEAD>

<body bgcolor="#8fbc8f" text="#faebd7"

link="#aaaacc" vlink="#aaaaee" alink="#ccbbbb">

<FORM NAME="myform">

Enter your Password:

<INPUT TYPE="text" NAME="inputbox" VALUE="">

<INPUT TYPE="button" NAME="button"

Value="Touch Here for Access"

onClick="testResults(this.form)">

</FORM>

</BODY>

</HTML>

With this sort of online verification, you can control access to certain pages or directories. This self-contained forms and data verification gives JavaScript its strength.

Client-side JavaScript's real benefit is that you don't need to connect to the server and use CPU cycles and bandwidth. With this method, you would only use the server-side JavaScript to create pages on the fly from a database. It would pull all relevant information from the database and append it to a newly created page that would, in turn, be sent to the client.

For the latest information on how to create sophisticated JavaScript, visit the JavaScript 411 site at http://www.freqgrafx.com/411. To peruse the official online JavaScript documentation from Netscape, go to http://HOME.NETSCAPE.COM/comprod/products/navigator/version_2.0/script/index.html.

Back to 10/96 Features: Form-id able Function
Up to Table of Contents
Ahead to 10/96 Features: Form-id able Function