Back to Applets page
Click in the boxes below, select all and copy to grab the applet
HTML listing:
<HTML> <HEAD> <TITLE>Listing 11.4</TITLE> <SCRIPT LANGUAGE="JAVASCRIPT"> <!-- Hide script from old browsers function passCheck(passForm) { goodPass = false if (passForm.pass.value != "") { goodPass = document.javaCheck.checkPass(passForm.pass.value) } if (!goodPass) { alert("Invalid password") passForm.pass.focus() passForm.pass.select() } return goodPass } // End hiding script from old browsers --> </SCRIPT> </HEAD> <BODY BGCOLOR=WHITE> You'll have to enter the secret password to see that page...<br> <FORM METHOD="post" ACTION="javascript:document.location='http://www.chalcedony.com/java/'" onSubmit="return passCheck(this)"> Enter password: <INPUT TYPE="text" NAME="pass"><br><br> <INPUT TYPE="submit" value="Submit"> </FORM> <APPLET CODEBASE="classes" CODE="Applet2.class" WIDTH=1 HEIGHT=1 NAME="javaCheck"> </APPLET> </BODY> </HTML>
Applet listing:
import java.applet.*; public class Applet2 extends Applet { public boolean checkPass(String s) { return (s.equals("peachpit")); } }