First, create a simple form and use the NAME attribute to name it “yourForm.” Although a form name technically isn’t required, it’s still a good idea to name your forms and form elements. Form names and element names are recommended if you plan to process the form using a CGI script.
<!– hide script from older browsers
alert(“Please enter your full name.”);
alert(“Please enter your email address.”);
alert(“Please enter your phone number.”);
stop hiding script –>
Note the syntax we use to refer to the form and text box:document.forms.yourForm.fullName.value
This specifically identifies the form named “yourForm” and the text box named “fullName.” It’s important to be this specific to avoid confusion – especially when there’s more than one form on the Web page.
Then, include an onSubmit statement that calls the function when the form is submitted. Include it inside the opening FORM tag:<form name=”yourForm” method=”post” action=””