Tizen 2.1 base
[platform/framework/web/web-ui-fw.git] / libs / js / jquery-mobile-1.0.1pre / docs / forms / textinputs / index.html
1 <!DOCTYPE html> 
2 <html> 
3         <head>
4         <meta charset="utf-8">
5         <meta name="viewport" content="width=device-width, initial-scale=1"> 
6         <title>jQuery Mobile Docs - Text inputs</title> 
7         <link rel="stylesheet"  href="../../../css/themes/default/" />  
8         <link rel="stylesheet" href="../../_assets/css/jqm-docs.css"/>
9         <script src="../../../js/jquery.js"></script>
10         <script src="../../../experiments/themeswitcher/jquery.mobile.themeswitcher.js"></script>
11         <script src="../../_assets/js/jqm-docs.js"></script>
12         <script src="../../../js/"></script>
13 </head> 
14 <body> 
15
16         <div data-role="page" class="type-interior">
17
18                 <div data-role="header" data-theme="f">
19                 <h1>Text inputs</h1>
20                 <a href="../../../" data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-right jqm-home">Home</a>
21         </div><!-- /header -->
22
23         <div data-role="content">
24                 <div class="content-primary">
25                 
26                 <form action="#" method="get">
27
28                         <h2>Text inputs & Textareas</h2>
29                         
30                         <ul data-role="controlgroup" data-type="horizontal" class="localnav">
31                                 <li><a href="index.html" data-role="button" data-transition="fade" class="ui-btn-active">Basics</a></li>
32                                 <li><a href="options.html" data-role="button" data-transition="fade">Options</a></li>
33                                 <li><a href="methods.html" data-role="button" data-transition="fade">Methods</a></li>
34                                 <li><a href="events.html" data-role="button" data-transition="fade">Events</a></li>
35                         </ul>
36
37                         <p>Text inputs and textareas are coded with standard HTML elements, then enhanced by jQuery Mobile to make them more attractive and useable on a mobile device. View the <a href="../../api/data-attributes.html">data- attribute reference</a> to see all the possible attributes you can add to text inputs.</p>
38                         
39                         <h2>Text inputs</h2>
40                         <p>To collect standard alphanumeric text, use an <code>input</code> with a <code>type="text"</code> attribute. Set the <code>for</code> attribute of the <code>label</code> to match the ID of the <code>input</code> so they are semantically associated. It's possible to <a href="../docs-forms.html">accessibly hide the label</a> if it's not desired in the page layout, but we require that it is present in the markup for semantic and accessibility reasons.</p>
41
42 <pre><code>     
43     &lt;label for=&quot;basic&quot;&gt;Text Input:&lt;/label&gt;
44     &lt;input type=&quot;text&quot; name=&quot;name&quot; id=&quot;basic&quot; value=&quot;&quot;  /&gt;
45 </code></pre>           
46
47                         <p>This will produce a basic text input. The default styles set the width of the input to 100% of the parent container and stacks the label on a separate line.</p>
48                         
49                  <label for="basic">Text Input:</label>
50                  <input type="text" name="name" id="basic" value="" />
51
52                         <p>Optionally wrap the text input in a container with the <code> data-role="fieldcontain"</code> attribute to help visually group it in a longer form.</p>
53
54 <pre><code>     
55 <strong>&lt;div data-role=&quot;fieldcontain&quot;&gt;
56 </strong>    &lt;label for=&quot;name&quot;&gt;Text Input:&lt;/label&gt;
57     &lt;input type=&quot;text&quot; name=&quot;name&quot; id=&quot;name&quot; value=&quot;&quot;  /&gt;
58 <strong>&lt;/div&gt;    
59 </strong></code></pre>          
60                          
61                         <p>The text input is now displayed like this:</p>
62                 <div data-role="fieldcontain">
63                  <label for="name">Text Input:</label>
64                  <input type="text" name="name" id="name" value="" />
65                         </div>
66                                                 
67                         
68                         <h3>More text input types</h3>
69                         <p>In jQuery Mobile, you can use existing and new HTML5 input types such as <code>password</code>, <code>email</code>, <code>tel</code>, <code>number</code>, and more.  Some type values are rendered differently across browsers &#8212; for example, Chrome displays the <code>range</code> input renders as a slider &#8212; so we standardize their appearance by dynamically changing their type to <code>text</code> (currently, this applies to <code>range</code> and <code>search</code>). You can configure which input types are degraded to <code>text</code> with the <code>page</code> plugin's options.</p>
70                         
71                         <p>One major advantage of using these more specific input types if that on mobile devices, specialized keyboards that speed data entry are offered in place of the standard text keyboard. Try the followin inputs on a mobile device to see which display custom keyboards on various platforms.</p>
72                         
73                         <div data-role="fieldcontain">
74                  <label for="password">Password:</label>
75                  <input type="password" name="password" id="password" value="" />
76                         </div>
77                         
78                         <div data-role="fieldcontain">
79                  <label for="number">Number:</label>
80                  <input type="number" name="number" id="number" value="" />
81                         </div>
82                         
83                         <div data-role="fieldcontain">
84                  <label for="email">Email:</label>
85                  <input type="email" name="email" id="email" value="" />
86                         </div>
87                         
88                         <div data-role="fieldcontain">
89                  <label for="url">Url:</label>
90                  <input type="url" name="url" id="url" value="" />
91                         </div>
92                         
93                         <div data-role="fieldcontain">
94                  <label for="tel">Tel:</label>
95                  <input type="tel" name="tel" id="tel" value="" />
96                         </div>
97                         
98                         <div data-role="fieldcontain">
99                  <label for="time">Time:</label>
100                  <input type="time" name="time" id="time" value="" />
101                         </div>
102                         
103                         <div data-role="fieldcontain">
104                  <label for="date">Date:</label>
105                  <input type="date" name="date" id="date" value="" />
106                         </div>
107                         
108                         <div data-role="fieldcontain">
109                  <label for="month">Month:</label>
110                  <input type="month" name="month" id="month" value="" />
111                         </div>
112                         
113                         <div data-role="fieldcontain">
114                  <label for="week">Week:</label>
115                  <input type="week" name="week" id="week" value="" />
116                         </div>
117                         
118                         <div data-role="fieldcontain">
119                  <label for="datetime">Datetime:</label>
120                  <input type="datetime" name="datetime" id="datetime" value="" />
121                         </div>
122                         
123                         <div data-role="fieldcontain">
124                  <label for="datetime-l">Datetime local:</label>
125                  <input type="datetime-local" name="datetime-l" id="datetime-l" value="" />
126                         </div>
127                         
128                         <div data-role="fieldcontain">
129                  <label for="color">Color:</label>
130                  <input type="color" name="color" id="color" value="" />
131                         </div>
132                         
133                         
134                         
135                         <h2>Textareas</h2>
136                         <p>For multi-line text inputs, use a <code>textarea</code> element. The framework will auto-grow the height of the textarea to avoid the need for an internal scrollbar. </p>
137                         <p>Set the <code>for</code> attribute of the <code>label</code> to match the ID of the <code>textarea</code> so they are semantically associated, and wrap them in a <code>div</code> with the <code> data-role="fieldcontain"</code> attribute to group them.</p>
138
139 <pre><code>     
140 <strong>&lt;label for=&quot;textarea-a&quot;&gt;Textarea:&lt;/label&gt;
141 &lt;textarea name=&quot;textarea&quot; id=&quot;textarea-a&quot;&gt;</strong>
142 I&#x27;m a basic textarea. If this is pre-populated with content, the height will be automatically adjusted to fit without needing to scroll. That is a pretty handy usability feature.
143 <strong>&lt;/textarea&gt;</strong>
144 </code></pre>   
145
146                         <p>This will produce a basic textarea with the width set to 100% of the parent container and the label stacked on a separate line.The textarea will grow to fit new lines as you type:</p>
147                         <label for="textarea-a">Textarea:</label>
148                         <textarea name="textarea" id="textarea-a">
149 I'm a basic textarea. If this is pre-populated with content, the height will be automatically adjusted to fit without needing to scroll. That is a pretty handy usability feature.
150                         </textarea>
151
152 <pre><code>     
153 <strong>&lt;div data-role=&quot;fieldcontain&quot;&gt;
154 </strong>&lt;label for=&quot;textarea&quot;&gt;Textarea:&lt;/label&gt;
155         &lt;textarea name=&quot;textarea&quot; id=&quot;textarea&quot;&gt;&lt;/textarea&gt;
156 <strong>&lt;/div&gt;</strong>
157 </code></pre>   
158                          
159                         <p>The textarea is displayed like this and will grow to fit new lines as you type:</p>
160                         <div data-role="fieldcontain">
161                         <label for="textarea">Textarea:</label>
162                         <textarea name="textarea" id="textarea"></textarea>
163                         </div>
164                         
165                         
166                         <h2>Calling the textinput plugin</h2>
167
168                         <p>This plugin will auto initialize on any page that contains a textarea or any of the text input types listed above, no need for a <code>data-role</code> attribute in the markup. However, if needed you can directly call the <code>textinput</code> plugin on any selector, just like any jQuery plugin:</p>
169                         <pre><code>
170 $('input').textinput();                 
171                         </code></pre>
172                         
173                         
174                         <h2>Degraded input types</h2>
175                         <p>jQuery Mobile degrades several HTML5 input types back to type=text, or type=number after adding enhanced controls. For example, inputs with a type of range are enhanced with a custom slider control, and their type is set to number to offer a usable form input alongside that slider. Inputs with a type of search are degraded back to type=text after we add our own themable search input styling.</p>
176                         <p>The page plugin contains a list of input types that are set to either true which means they'll degrade to type=text, false which means they'll be left alone, or a string such as "number", which means they'll be converted to that type (such as the case of type=range).</p>
177                 
178                         <p>You can configure which types are changed via the page plugin's <code>degradeInputs</code> option, which can be manipulated externally via <code>$.mobile.page.prototype.options.degradeInputs</code>, which has properties: color, date, datetime, "datetime-local", email, month, number, range, search, tel, time, url, and week. Be sure to configure this inside an event handler bound to the <code>mobileinit</code> event, so that it applies to the first page as well as subsequent pages that are loaded.</p>     
179                 
180
181         </form>
182         
183         </div><!--/content-primary -->          
184         
185         <div class="content-secondary">
186                 
187                 <div data-role="collapsible" data-collapsed="true" data-theme="b" data-content-theme="d">
188                         
189                                 <h3>More in this section</h3>
190                                 
191                                 <ul data-role="listview" data-theme="c" data-dividertheme="d">
192                                 
193                                         <li data-role="list-divider">Form elements</li>
194                                         <li><a href="../docs-forms.html">Form basics</a></li>
195                                         <li><a href="../forms-all.html">Form element gallery</a></li>
196                                         <li data-theme="a"><a href="index.html">Text inputs</a></li>
197                                         <li><a href="../search/">Search input</a></li>
198                                         <li><a href="../slider/">Slider</a></li>
199                                         <li><a href="../switch/">Flip toggle switch</a></li>
200                                         <li><a href="../radiobuttons/">Radio buttons</a></li>
201                                         <li><a href="../checkboxes/">Checkboxes</a></li>
202                                         <li><a href="../selects/">Select menus</a></li>
203                                         <li><a href="../forms-themes.html">Theming forms</a></li>
204                                         <li><a href="../forms-all-native.html">Native form elements</a></li>
205                                         <li><a href="../forms-sample.html">Submitting forms</a></li>
206                                         
207         
208                                 </ul>
209                 </div>
210         </div>          
211
212 </div><!-- /content -->
213
214 <div data-role="footer" class="footer-docs" data-theme="c">
215                 <p>&copy; 2011 The jQuery Project</p>
216 </div>
217         
218 </div><!-- /page -->
219
220 </body>
221 </html>