HTML and CSS Reference
Type your name here:
<input type="text" name="namestring" size="50">
<input type="submit" value="Submit" />
<input type="reset" value="Clear" />
The function called checkForm() has one parameter, yourinfo , which is a reference
to the form defined on line 6.
If the user didn't enter anything into the textbox, the value of the input type will
be null. The expression if(yourinfo.namestring.value == “”) checks for an empty
The user didn't enter anything into the textbox, an alert dialog box will appear on
the screen, and after he presses OK, he will have a chance to fill out the form
If false is returned from this function, the form will not be submitted to the server.
If true is returned from this function, the form will be submitted to the server.
The HTML form starts here. The form, document.forms , is named info . The ac-
tion attribute contains the URL of the program that will process the form, a CGI
script on the server. The method attribute defines the HTTP method that deter-
mines how the data will be sent to the server.
The onSubmit event is an attribute of the HTML <form> tag. It is triggered when
the user clicks the Submit button. The event handler is a function called check-
Form() . Its argument is this, same as document.forms ). The return keyword is
required when using the onSubmit event handler. One of two values will be re-
turned: either true or false .
The input type for this form is a text field box. Its name is namestring and it can
hold a string of up to 50 characters.
The input type is the Submit button. When the user clicks this button, the onSub-
mit event handler on line 7 is activated. See Figure 11.46.