Pages

Men

rh

10/15/2014

HTML Part - 3

Demo with New Input attributes

New type values

Earlier developer were using different libraries in order to get different UI elements such as datepicker, range picker, color picker etc.
Now HTML 5 brought standard by introducing new attributes to “type” attribute of input elements.
Let’s look at some of them.
  • Number
<input type="number" name="MyNuberElement" id="MyNumberElement" />

  • Range
<input type="range" name="MyRangeElement" id="MyRangeElement"/>
  • Color
<input type="color" id="MyColorElement" name="MyColorElement" />
  • Date
<input type="date" id="MyDateElement" name="MyDateElement" />
  • Time
<input type="time" id="MyTimeElement" name="MyTimeElement"/>
  • Datetime-local
<input type="datetime-local" id="MyDateTimeLElement" name="MyDateTimeLElement" />
  • DateTime (Also include time zone)
<input type="datetime" id="MyDateTimeElement" name="MyDateTimeElement"/>
  • Month
<input type="month" id="MyMonthElement" name="MyMonthElement" />
  • Week
<input type="week" id="MyWeekElement" name="MyWeekElement" />

Some useful attributes

  • Autofocus
This attribute let us set initial focus on page load.
&hellip;

<label for="birthMonth">Birth Month</label>

<input type="month" id="MyMonthElement" name="MyMonthElement" autofocus />

&hellip;
This code makes focus to be set on “MyMonthElement” control element by default when page loads for the first time.
Note: In case “autofocus” is attached to multiple controls focus will be set on first control.
  • Placeholder
Let us set watermark on an input control.
<input type="text" placeholder="Enter Value" id="MyPlaceHolderControl"

               name="MyPlaceHolderControl" />
                                                      Source collected from CodeProject.com

No comments :

Post a Comment