Skip to Main Content or Page Contents
text box: Simple: Single line Text Box
text box: Improved: Single line Text Box using 'label for & an ID'
text box: placeholder: Single line Text Box with the label inside the text box
text box Simple Single line Text Box
textarea Multi line Text Box
radio Round Button
checkbox Square check (tick) box
hidden
password
submit
reset
color, date, datetime-local, email, month, number range, search, tel, time, url, week,
HTML Forms are used to obtain information from your web page visitor. If you look at a form you may think that they would be hard to produce, when they are quite simple.
Probably the harder part is transferring the data back to where it can be used. I therefore suggest that at your first attempt you produce a very simple form that collects 1 or 2 items of information, a persons name then have that name e-mailed to your e-mail address.
Usually the data inputted in a form is processed by a Common Gateway Interface Script (CGI Script). These scripts are usually written in Perl.
Not all Hosting Servers allow these scripts, or it may cost more money to use them. Questions to ask your host. For security reasons hosts like to have full control over scripts.
Submit the Information
<form action="form-sample.php" method="post">
</form>
Or
<form action="form-sample.php" method="get">
</form>
There are several different ways of obtaining information. Choose a way that makes it easy for the user to enter the information.
These are various types of input boxes that you can use: radio Round Button, checkbox Square check (tick) box, text Single line Text Box, textarea Multi- line Text Box, hidden, password, submit, reset,
color, date, datetime-local, email, month, number range, search, tel, time, url, week,
HTML
Text Box Improved Example
HTML
HTML
Result
Defines a radio button.
Radio buttons let a user select ONE of a listed number of choices:
Example, Select your Age group
<form>
<p>Example, Select your Age group</p>
<input type="radio" name="Age-Group" value=" 21 or under" checked>21 or under<br> <input type="radio" name="Age-Group" value="22 to 64">22 to 64<br>
<input type="radio" name="Age-Group" value=Pensioner"> Pensioner
</form>
The page designer can pre select one of the options by placing the attribute checked at the end of the desired value.
Note: The user can still select any of the options
Select your Favourite Colour(s)
White
maxlength, size,
HTML5 added the following attributes for <input>:
autocomplete, autofocus, form, formaction, formenctype, formmethod, formnovalidate, formtarget, height and width, list, min and max, multiple, pattern (regexp), placeholder, required, size, step.
and the following attributes for <form>:
autocomplete, novalidate.
placeholder & size Example
HTML
text box: placeholder:
<script type="text/javascript">
function hgsubmit()
{ if (/\S+/.test(document.hgmailer.name.value) == false) alert ("Please provide your name.");
else if (/^\S+@[a-z0-9_.-]+\.[a-z]{2,6}$/i.test(document.hgmailer.email.value) == false) alert ("A valid email address is required.");
else if (/\S+/.test(document.hgmailer.comment.value) == false) alert ("Your email content is needed.");
else { document.hgmailer.submit(); alert (' Thank you! \n Your email is sent.'); } }
</script>
This site is hosted on Hostgator