Monday, 3 February 2014

HTML5 Form Elements

HTML5 Form Elements


HTML5 New Form Elements

HTML5 has the following new form elements:
  • <datalist>
  • <keygen>
  • <output>
NoteNot all browsers support all the new form elements. However, you can already start using them; If they are not supported, they will behave as regular text fields.


HTML5 <datalist> Element

The <datalist> element specifies a list of pre-defined options for an <input> element.
The <datalist> element is used to provide an "autocomplete" feature on <input> elements. Users will see a drop-down list of pre-defined options as they input data.
Use the <input> element's list attribute to bind it together with a <datalist> element.
OperaSafariChromeFirefoxInternet Explorer

Example

An <input> element with pre-defined values in a <datalist>:
<input list="browsers">

<datalist id="browsers">
  <option value="Internet Explorer">
  <option value="Firefox">
  <option value="Chrome">
  <option value="Opera">
  <option value="Safari">
</datalist>



HTML5 <keygen> Element

The purpose of the <keygen> element is to provide a secure way to authenticate users.
The <keygen> tag specifies a key-pair generator field in a form.
When the form is submitted, two keys are generated, one private and one public.
The private key is stored locally, and the public key is sent to the server. The public key could be used to generate aclient certificate to authenticate the user in the future.
OperaSafariChromeFirefoxInternet Explorer

Example

A form with a keygen field:
<form action="demo_keygen.asp" method="get">
Username: <input type="text" name="usr_name">
Encryption: <keygen name="security">
<input type="submit">
</form>



HTML5 <output> Element

The <output> element represents the result of a calculation (like one performed by a script).
OperaSafariChromeFirefoxInternet Explorer

Example

Perform a calculation and show the result in an <output> element:
<form oninput="x.value=parseInt(a.value)+parseInt(b.value)">0
<input type="range" id="a" value="50">100 +
<input type="number" id="b" value="50">=
<output name="x" for="a b"></output>
</form>



HTML5 New Form Elements

TagDescription
<datalist>Specifies a list of pre-defined options for an <input> element
<keygen>Specifies a key-pair generator field in a form
<output>Represents the result of a calculation

Related Posts:

  • Game development Space Invaders in C# and .NET Source code Download Figure 1 - The Space Invader Game Yes, the classic arcade game has returned and is appearing in C# Corner complete with sound and authentic aliens and source code… Read More
  • ASP.NET - Debugging ASP.NET - Debugging Debugging allows the developers to watch how the code works in a step-by-step manner, how the values of the variables change, how the objects are created and destroyed etc. When the site is run for th… Read More
  • Game Development - part 2 Considerations in Porting and Deploying a WinForms GDI+ Game to the Pocket PC Figure 1 - PocketPC game running on the Windows Mobile Emulator Introduction The next big frontier is around the corner.  That's… Read More
  • Real Time 3D Physics Simulation Using Peace Engine Real Time 3D Physics Simulation Using Peace Engine IntroductionThe idea for using 3D or a Physics engine is to reduce the amount of time and lines of code. So you can write your application without implementing the low-le… Read More
  • ASP.NET - Error Handling ASP.NET - Error Handling Error handling in ASP.Net has three aspects: Tracing - tracing the program execution at page level or application level. Error handling - handling standard errors or custom errors at… Read More

0 comments:

Post a Comment