How to program a guestbook? Guestbook programming is not difficult, and there are many options for implementing it, such as CGI programs and more. This article introduces how to use JavaScript to program a guestbook. Below is a complete example.
----We provide a form with name, email address of the guest, browser version used, country name, comments and suggestions, favorite sites, etc. After the guest fills out these fields, press the Submit button, and the information will be emailed to you. The program provides several functions, most of which are used to check the validity of fields. Below we give a brief explanation of the function.
----Function Reset() resets the contents of each field after pressing the Reset button.
----The function submitForms() presses the submit button and checks the validity of the fields before sending an email.
----The function isName() checks the validity of the name field.
----The function isEmail() checks the validity of the email address field.
----The function isBrowser() compares the browser field with the automatically detected browser version.
----The function isCountry() checks the validity of the country field.
----The function isComment() checks the validity of the opinion field and does not allow null values.
----The function isFavorite() checks the validity of the favorite site field and does not allow null values.
----The program also provides some skills, such as how to determine the browser version, string operations, etc.
----The results are provided to you in the form of an email with various fields entered by the guest. The program is relatively long, but not difficult to understand. Here is the source code: