Java Script and Forms
In this tutorial you will learn how to read HTML forms and validate an HTML form using JavaScript.
At the heart of the Web is the form. It is used to pass information from the browser to the server. Anytime you go online and order a book, trade at an auction, fill out a survey, or send an e-mail using a Web browser, you are working with a form.
An HTML form offers you a number of ways to accept input, such as radio buttons, check boxes, popup menus, hidden fields, and text boxes; these are called virtual input devices or controls. Once the form has been filled out by a user, it normally is sent to a server where the input is processed by a server-side program, such as a Java servlet, CGI, ASP.NET, or PHP application. It is important to understand how the form data is collected and sent to the server and then what role JavaScript has in this process.
Attributes of the <form>Tag
All forms are in HTML documents. They begin with a <form> tag and its attributes, followed by the input fields where the user enters form information, and end with a </form> tag.<form name="form1" id="form1" action="URL to server program" method="post"> <input type="text" name="town" id="town"> </form>
The name Attribute. The name is simply a name for the form. You can use forms without giving them names, but you’ll need to assign a name to a form in order to easily use it with JavaScript.
The action Attribute. The action attribute is assigned the URL of the server program that will process the form data.
The method Attribute. A method attribute can be assigned to the