001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.juneau.bean.html5; 018 019import java.net.*; 020 021import org.apache.juneau.annotation.*; 022 023/** 024 * DTO for an HTML <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#the-input-element"><input></a> 025 * element. 026 * 027 * <p> 028 * The input element represents a form control that allows users to input data. It is a void element 029 * that can take many different forms depending on the type attribute, including text fields, checkboxes, 030 * radio buttons, file uploads, and more. The input element is one of the most versatile and commonly 031 * used form controls in HTML. 032 * 033 * <h5 class='section'>Examples:</h5> 034 * <p class='bcode w800'> 035 * <jk>import static</jk> org.apache.juneau.bean.html5.HtmlBuilder.*; 036 * 037 * <jc>// Text input field</jc> 038 * Input <jv>input1</jv> = <jsm>input</jsm>(<js>"text"</js>) 039 * .name(<js>"username"</js>) 040 * .placeholder(<js>"Enter your username"</js>) 041 * .required(<jk>true</jk>); 042 * 043 * <jc>// Email input with validation</jc> 044 * Input <jv>input2</jv> = <jsm>input</jsm>(<js>"email"</js>) 045 * .name(<js>"email"</js>) 046 * .placeholder(<js>"your@email.com"</js>) 047 * .autocomplete(<js>"email"</js>); 048 * 049 * <jc>// File upload input</jc> 050 * Input <jv>input3</jv> = <jsm>input</jsm>(<js>"file"</js>) 051 * .name(<js>"avatar"</js>) 052 * .accept(<js>"image/*"</js>) 053 * .multiple(<jk>true</jk>); 054 * 055 * <jc>// Checkbox input</jc> 056 * Input <jv>input4</jv> = <jsm>input</jsm>(<js>"checkbox"</js>) 057 * .name(<js>"subscribe"</js>) 058 * .value(<js>"yes"</js>) 059 * .checked(<jk>true</jk>); 060 * 061 * <jc>// Password input with pattern</jc> 062 * Input <jv>input5</jv> = <jsm>input</jsm>(<js>"password"</js>) 063 * .name(<js>"password"</js>) 064 * .pattern(<js>".{8,}"</js>) 065 * .title(<js>"Password must be at least 8 characters"</js>); 066 * </p> 067 * 068 * <p> 069 * The following convenience methods are provided for constructing instances of this bean: 070 * <ul class='javatree'> 071 * <li class='jc'>{@link HtmlBuilder} 072 * <ul class='javatree'> 073 * <li class='jm'>{@link HtmlBuilder#input() input()} 074 * <li class='jm'>{@link HtmlBuilder#input(String) input(String)} 075 * </ul> 076 * </ul> 077 * </p> 078 * 079 * <h5 class='section'>See Also:</h5><ul> 080 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauBeanHtml5">juneau-bean-html5</a> 081 * </ul> 082 */ 083@Bean(typeName = "input") 084public class Input extends HtmlElementVoid { 085 086 /** 087 * Creates an empty {@link Input} element. 088 */ 089 public Input() {} 090 091 /** 092 * Creates an {@link Input} element with the specified {@link Input#type(String)} attribute. 093 * 094 * @param type The {@link Input#type(String)} attribute. 095 */ 096 public Input(String type) { 097 type(type); 098 } 099 100 @Override /* Overridden from HtmlElement */ 101 public Input _class(String value) { // NOSONAR - Intentional naming. 102 super._class(value); 103 return this; 104 } 105 106 /** 107 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-input-accept">accept</a> attribute. 108 * 109 * <p> 110 * Specifies which file types the file input should accept. Used with <c>type="file"</c>. 111 * 112 * <p> 113 * Examples: 114 * <ul> 115 * <li><js>"image/*"</js> - Accept all image files</li> 116 * <li><js>".pdf,.doc,.docx"</js> - Accept specific file extensions</li> 117 * <li><js>"image/png,image/jpeg"</js> - Accept specific MIME types</li> 118 * </ul> 119 * 120 * @param value File type restrictions for file uploads. 121 * @return This object. 122 */ 123 public Input accept(String value) { 124 attr("accept", value); 125 return this; 126 } 127 128 @Override /* Overridden from HtmlElement */ 129 public Input accesskey(String value) { 130 super.accesskey(value); 131 return this; 132 } 133 134 /** 135 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-input-alt">alt</a> attribute. 136 * 137 * <p> 138 * Alternative text for image submit buttons. Used with <c>type="image"</c> to provide 139 * accessible text when the image cannot be displayed. 140 * 141 * @param value Alternative text for image submit buttons. 142 * @return This object. 143 */ 144 public Input alt(String value) { 145 attr("alt", value); 146 return this; 147 } 148 149 @Override /* Overridden from HtmlElement */ 150 public Input attr(String key, Object val) { 151 super.attr(key, val); 152 return this; 153 } 154 155 @Override /* Overridden from HtmlElement */ 156 public Input attrUri(String key, Object val) { 157 super.attrUri(key, val); 158 return this; 159 } 160 161 /** 162 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-fe-autocomplete">autocomplete</a> attribute. 163 * 164 * <p> 165 * Controls whether the browser can automatically complete the input field. 166 * 167 * <p> 168 * Common values: 169 * <ul> 170 * <li><js>"on"</js> - Allow autocomplete (default)</li> 171 * <li><js>"off"</js> - Disable autocomplete</li> 172 * <li><js>"name"</js> - Full name</li> 173 * <li><js>"email"</js> - Email address</li> 174 * <li><js>"username"</js> - Username or login</li> 175 * <li><js>"current-password"</js> - Current password</li> 176 * <li><js>"new-password"</js> - New password</li> 177 * <li><js>"tel"</js> - Telephone number</li> 178 * <li><js>"url"</js> - URL</li> 179 * <li><js>"address-line1"</js> - Street address</li> 180 * <li><js>"country"</js> - Country name</li> 181 * <li><js>"postal-code"</js> - Postal code</li> 182 * </ul> 183 * 184 * @param value Autocomplete hint for the input field. 185 * @return This object. 186 */ 187 public Input autocomplete(String value) { 188 attr("autocomplete", value); 189 return this; 190 } 191 192 /** 193 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-fe-autofocus">autofocus</a> attribute. 194 * 195 * <p> 196 * Automatically focuses the form control when the page loads. 197 * Only one element per page should have this attribute. 198 * 199 * @param value 200 * The new value for this attribute. 201 * Typically a {@link Boolean} or {@link String}. 202 * @return This object. 203 */ 204 public Input autofocus(Object value) { 205 attr("autofocus", value); 206 return this; 207 } 208 209 /** 210 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-input-checked">checked</a> attribute. 211 * 212 * <p> 213 * Whether the command or control is checked. 214 * 215 * <p> 216 * This attribute uses deminimized values: 217 * <ul> 218 * <li><jk>false</jk> - Attribute is not added</li> 219 * <li><jk>true</jk> - Attribute is added as <js>"checked"</js></li> 220 * <li>Other values - Passed through as-is</li> 221 * </ul> 222 * 223 * @param value 224 * The new value for this attribute. 225 * Typically a {@link Boolean} or {@link String}. 226 * @return This object. 227 */ 228 public Input checked(Object value) { 229 attr("checked", deminimize(value, "checked")); 230 return this; 231 } 232 233 @Override /* Overridden from HtmlElement */ 234 public Input contenteditable(Object value) { 235 super.contenteditable(value); 236 return this; 237 } 238 239 @Override /* Overridden from HtmlElement */ 240 public Input dir(String value) { 241 super.dir(value); 242 return this; 243 } 244 245 /** 246 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-fe-dirname">dirname</a> attribute. 247 * 248 * <p> 249 * Specifies the name of a hidden form field that will be submitted along with the input value, 250 * containing the text direction (ltr or rtl) of the input content. 251 * 252 * <p> 253 * This is useful for forms that need to preserve text direction information when submitted. 254 * The hidden field will contain either "ltr" or "rtl" based on the input's direction. 255 * 256 * @param value The name of the hidden field for directionality information. 257 * @return This object. 258 */ 259 public Input dirname(String value) { 260 attr("dirname", value); 261 return this; 262 } 263 264 /** 265 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-fe-disabled">disabled</a> attribute. 266 * 267 * <p> 268 * Whether the form control is disabled. 269 * 270 * <p> 271 * This attribute uses deminimized values: 272 * <ul> 273 * <li><jk>false</jk> - Attribute is not added</li> 274 * <li><jk>true</jk> - Attribute is added as <js>"disabled"</js></li> 275 * <li>Other values - Passed through as-is</li> 276 * </ul> 277 * 278 * @param value 279 * The new value for this attribute. 280 * Typically a {@link Boolean} or {@link String}. 281 * @return This object. 282 */ 283 public Input disabled(Object value) { 284 attr("disabled", deminimize(value, "disabled")); 285 return this; 286 } 287 288 /** 289 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-fae-form">form</a> attribute. 290 * 291 * <p> 292 * Associates the input with a form element by specifying the form's ID. This allows the input 293 * to be placed outside the form element while still being part of the form. 294 * 295 * <p> 296 * The value should match the ID of a form element in the same document. 297 * 298 * @param value The ID of the form element to associate with this input. 299 * @return This object. 300 */ 301 public Input form(String value) { 302 attr("form", value); 303 return this; 304 } 305 306 /** 307 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-fs-formaction">formaction</a> attribute. 308 * 309 * <p> 310 * URL to use for form submission. 311 * 312 * @param value The new value for this attribute. 313 * @return This object. 314 */ 315 public Input formaction(String value) { 316 attr("formaction", value); 317 return this; 318 } 319 320 /** 321 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-fs-formenctype">formenctype</a> attribute. 322 * 323 * <p> 324 * Form data set encoding type to use for form submission. 325 * 326 * @param value The new value for this attribute. 327 * @return This object. 328 */ 329 public Input formenctype(String value) { 330 attr("formenctype", value); 331 return this; 332 } 333 334 /** 335 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-fs-formmethod">formmethod</a> attribute. 336 * 337 * <p> 338 * HTTP method to use for form submission. 339 * 340 * @param value The new value for this attribute. 341 * @return This object. 342 */ 343 public Input formmethod(String value) { 344 attr("formmethod", value); 345 return this; 346 } 347 348 /** 349 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-fs-formnovalidate">formnovalidate</a> 350 * attribute. 351 * 352 * <p> 353 * Bypass form control validation for form submission. 354 * 355 * @param value The new value for this attribute. 356 * @return This object. 357 */ 358 public Input formnovalidate(String value) { 359 attr("formnovalidate", value); 360 return this; 361 } 362 363 /** 364 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-fs-formtarget">formtarget</a> attribute. 365 * 366 * <p> 367 * Browsing context for form submission. 368 * 369 * @param value The new value for this attribute. 370 * @return This object. 371 */ 372 public Input formtarget(String value) { 373 attr("formtarget", value); 374 return this; 375 } 376 377 /** 378 * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-dim-height">height</a> 379 * attribute. 380 * 381 * <p> 382 * Vertical dimension. 383 * 384 * @param value 385 * The new value for this attribute. 386 * Typically a {@link Number} or {@link String}. 387 * @return This object. 388 */ 389 public Input height(Object value) { 390 attr("height", value); 391 return this; 392 } 393 394 @Override /* Overridden from HtmlElement */ 395 public Input hidden(Object value) { 396 super.hidden(value); 397 return this; 398 } 399 400 @Override /* Overridden from HtmlElement */ 401 public Input id(String value) { 402 super.id(value); 403 return this; 404 } 405 406 /** 407 * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-input-inputmode">inputmode</a> 408 * attribute. 409 * 410 * <p> 411 * Provides a hint to browsers about the type of virtual keyboard to display on mobile devices. 412 * 413 * <p> 414 * Possible values: 415 * <ul> 416 * <li><js>"none"</js> - No virtual keyboard</li> 417 * <li><js>"text"</js> - Standard text keyboard (default)</li> 418 * <li><js>"tel"</js> - Numeric keypad for telephone numbers</li> 419 * <li><js>"url"</js> - Keyboard optimized for URLs</li> 420 * <li><js>"email"</js> - Keyboard optimized for email addresses</li> 421 * <li><js>"numeric"</js> - Numeric keypad</li> 422 * <li><js>"decimal"</js> - Numeric keypad with decimal point</li> 423 * <li><js>"search"</js> - Keyboard optimized for search</li> 424 * </ul> 425 * 426 * @param value The input modality hint for mobile keyboards. 427 * @return This object. 428 */ 429 public Input inputmode(String value) { 430 attr("inputmode", value); 431 return this; 432 } 433 434 @Override /* Overridden from HtmlElement */ 435 public Input lang(String value) { 436 super.lang(value); 437 return this; 438 } 439 440 /** 441 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-input-list">list</a> attribute. 442 * 443 * <p> 444 * References a <c><datalist></c> element that provides predefined options 445 * for the input field. Creates a dropdown with autocomplete suggestions. 446 * 447 * @param value The ID of a datalist element (without the # prefix). 448 * @return This object. 449 */ 450 public Input list(String value) { 451 attr("list", value); 452 return this; 453 } 454 455 /** 456 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-input-max">max</a> attribute. 457 * 458 * <p> 459 * Maximum value. 460 * 461 * @param value 462 * The new value for this attribute. 463 * Typically a {@link Number} or {@link String}. 464 * @return This object. 465 */ 466 public Input max(Object value) { 467 attr("max", value); 468 return this; 469 } 470 471 /** 472 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-input-maxlength">maxlength</a> attribute. 473 * Maximum length of value. 474 * 475 * @param value The new value for this attribute. 476 * Typically a {@link Number} or {@link String}. 477 * @return This object. 478 */ 479 public Input maxlength(Object value) { 480 attr("maxlength", value); 481 return this; 482 } 483 484 /** 485 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-input-min">min</a> attribute. 486 * 487 * <p> 488 * Minimum value. 489 * 490 * @param value 491 * The new value for this attribute. 492 * Typically a {@link Number} or {@link String}. 493 * @return This object. 494 */ 495 public Input min(Object value) { 496 attr("min", value); 497 return this; 498 } 499 500 /** 501 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-input-minlength">minlength</a> attribute. 502 * 503 * <p> 504 * Minimum length of value. 505 * 506 * @param value 507 * The new value for this attribute. 508 * Typically a {@link Number} or {@link String}. 509 * @return This object. 510 */ 511 public Input minlength(Object value) { 512 attr("minlength", value); 513 return this; 514 } 515 516 /** 517 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-input-multiple">multiple</a> attribute. 518 * 519 * <p> 520 * Whether to allow multiple values. 521 * 522 * <p> 523 * This attribute uses deminimized values: 524 * <ul> 525 * <li><jk>false</jk> - Attribute is not added</li> 526 * <li><jk>true</jk> - Attribute is added as <js>"multiple"</js></li> 527 * <li>Other values - Passed through as-is</li> 528 * </ul> 529 * 530 * @param value 531 * The new value for this attribute. 532 * Typically a {@link Boolean} or {@link String}. 533 * @return This object. 534 */ 535 public Input multiple(Object value) { 536 attr("multiple", deminimize(value, "multiple")); 537 return this; 538 } 539 540 /** 541 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-fe-name">name</a> attribute. 542 * 543 * <p> 544 * Name of form control to use for form submission and in the form.elements API. 545 * 546 * @param value The new value for this attribute. 547 * @return This object. 548 */ 549 public Input name(String value) { 550 attr("name", value); 551 return this; 552 } 553 554 @Override /* Overridden from HtmlElement */ 555 public Input onabort(String value) { 556 super.onabort(value); 557 return this; 558 } 559 560 @Override /* Overridden from HtmlElement */ 561 public Input onblur(String value) { 562 super.onblur(value); 563 return this; 564 } 565 566 @Override /* Overridden from HtmlElement */ 567 public Input oncancel(String value) { 568 super.oncancel(value); 569 return this; 570 } 571 572 @Override /* Overridden from HtmlElement */ 573 public Input oncanplay(String value) { 574 super.oncanplay(value); 575 return this; 576 } 577 578 @Override /* Overridden from HtmlElement */ 579 public Input oncanplaythrough(String value) { 580 super.oncanplaythrough(value); 581 return this; 582 } 583 584 @Override /* Overridden from HtmlElement */ 585 public Input onchange(String value) { 586 super.onchange(value); 587 return this; 588 } 589 590 @Override /* Overridden from HtmlElement */ 591 public Input onclick(String value) { 592 super.onclick(value); 593 return this; 594 } 595 596 @Override /* Overridden from HtmlElement */ 597 public Input oncuechange(String value) { 598 super.oncuechange(value); 599 return this; 600 } 601 602 @Override /* Overridden from HtmlElement */ 603 public Input ondblclick(String value) { 604 super.ondblclick(value); 605 return this; 606 } 607 608 @Override /* Overridden from HtmlElement */ 609 public Input ondurationchange(String value) { 610 super.ondurationchange(value); 611 return this; 612 } 613 614 @Override /* Overridden from HtmlElement */ 615 public Input onemptied(String value) { 616 super.onemptied(value); 617 return this; 618 } 619 620 @Override /* Overridden from HtmlElement */ 621 public Input onended(String value) { 622 super.onended(value); 623 return this; 624 } 625 626 @Override /* Overridden from HtmlElement */ 627 public Input onerror(String value) { 628 super.onerror(value); 629 return this; 630 } 631 632 @Override /* Overridden from HtmlElement */ 633 public Input onfocus(String value) { 634 super.onfocus(value); 635 return this; 636 } 637 638 @Override /* Overridden from HtmlElement */ 639 public Input oninput(String value) { 640 super.oninput(value); 641 return this; 642 } 643 644 @Override /* Overridden from HtmlElement */ 645 public Input oninvalid(String value) { 646 super.oninvalid(value); 647 return this; 648 } 649 650 @Override /* Overridden from HtmlElement */ 651 public Input onkeydown(String value) { 652 super.onkeydown(value); 653 return this; 654 } 655 656 @Override /* Overridden from HtmlElement */ 657 public Input onkeypress(String value) { 658 super.onkeypress(value); 659 return this; 660 } 661 662 @Override /* Overridden from HtmlElement */ 663 public Input onkeyup(String value) { 664 super.onkeyup(value); 665 return this; 666 } 667 668 @Override /* Overridden from HtmlElement */ 669 public Input onload(String value) { 670 super.onload(value); 671 return this; 672 } 673 674 @Override /* Overridden from HtmlElement */ 675 public Input onloadeddata(String value) { 676 super.onloadeddata(value); 677 return this; 678 } 679 680 @Override /* Overridden from HtmlElement */ 681 public Input onloadedmetadata(String value) { 682 super.onloadedmetadata(value); 683 return this; 684 } 685 686 @Override /* Overridden from HtmlElement */ 687 public Input onloadstart(String value) { 688 super.onloadstart(value); 689 return this; 690 } 691 692 @Override /* Overridden from HtmlElement */ 693 public Input onmousedown(String value) { 694 super.onmousedown(value); 695 return this; 696 } 697 698 @Override /* Overridden from HtmlElement */ 699 public Input onmouseenter(String value) { 700 super.onmouseenter(value); 701 return this; 702 } 703 704 @Override /* Overridden from HtmlElement */ 705 public Input onmouseleave(String value) { 706 super.onmouseleave(value); 707 return this; 708 } 709 710 @Override /* Overridden from HtmlElement */ 711 public Input onmousemove(String value) { 712 super.onmousemove(value); 713 return this; 714 } 715 716 @Override /* Overridden from HtmlElement */ 717 public Input onmouseout(String value) { 718 super.onmouseout(value); 719 return this; 720 } 721 722 @Override /* Overridden from HtmlElement */ 723 public Input onmouseover(String value) { 724 super.onmouseover(value); 725 return this; 726 } 727 728 @Override /* Overridden from HtmlElement */ 729 public Input onmouseup(String value) { 730 super.onmouseup(value); 731 return this; 732 } 733 734 @Override /* Overridden from HtmlElement */ 735 public Input onmousewheel(String value) { 736 super.onmousewheel(value); 737 return this; 738 } 739 740 @Override /* Overridden from HtmlElement */ 741 public Input onpause(String value) { 742 super.onpause(value); 743 return this; 744 } 745 746 @Override /* Overridden from HtmlElement */ 747 public Input onplay(String value) { 748 super.onplay(value); 749 return this; 750 } 751 752 @Override /* Overridden from HtmlElement */ 753 public Input onplaying(String value) { 754 super.onplaying(value); 755 return this; 756 } 757 758 @Override /* Overridden from HtmlElement */ 759 public Input onprogress(String value) { 760 super.onprogress(value); 761 return this; 762 } 763 764 @Override /* Overridden from HtmlElement */ 765 public Input onratechange(String value) { 766 super.onratechange(value); 767 return this; 768 } 769 770 @Override /* Overridden from HtmlElement */ 771 public Input onreset(String value) { 772 super.onreset(value); 773 return this; 774 } 775 776 @Override /* Overridden from HtmlElement */ 777 public Input onresize(String value) { 778 super.onresize(value); 779 return this; 780 } 781 782 @Override /* Overridden from HtmlElement */ 783 public Input onscroll(String value) { 784 super.onscroll(value); 785 return this; 786 } 787 788 @Override /* Overridden from HtmlElement */ 789 public Input onseeked(String value) { 790 super.onseeked(value); 791 return this; 792 } 793 794 @Override /* Overridden from HtmlElement */ 795 public Input onseeking(String value) { 796 super.onseeking(value); 797 return this; 798 } 799 800 @Override /* Overridden from HtmlElement */ 801 public Input onselect(String value) { 802 super.onselect(value); 803 return this; 804 } 805 806 @Override /* Overridden from HtmlElement */ 807 public Input onshow(String value) { 808 super.onshow(value); 809 return this; 810 } 811 812 @Override /* Overridden from HtmlElement */ 813 public Input onstalled(String value) { 814 super.onstalled(value); 815 return this; 816 } 817 818 @Override /* Overridden from HtmlElement */ 819 public Input onsubmit(String value) { 820 super.onsubmit(value); 821 return this; 822 } 823 824 @Override /* Overridden from HtmlElement */ 825 public Input onsuspend(String value) { 826 super.onsuspend(value); 827 return this; 828 } 829 830 @Override /* Overridden from HtmlElement */ 831 public Input ontimeupdate(String value) { 832 super.ontimeupdate(value); 833 return this; 834 } 835 836 @Override /* Overridden from HtmlElement */ 837 public Input ontoggle(String value) { 838 super.ontoggle(value); 839 return this; 840 } 841 842 @Override /* Overridden from HtmlElement */ 843 public Input onvolumechange(String value) { 844 super.onvolumechange(value); 845 return this; 846 } 847 848 @Override /* Overridden from HtmlElement */ 849 public Input onwaiting(String value) { 850 super.onwaiting(value); 851 return this; 852 } 853 854 /** 855 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-input-pattern">pattern</a> attribute. 856 * 857 * <p> 858 * Specifies a regular expression that the input's value must match for the form to be valid. 859 * Works with the <c>title</c> attribute to provide user feedback. 860 * 861 * @param value A regular expression pattern (e.g., <js>"[0-9]{3}-[0-9]{3}-[0-9]{4}"</js> for phone numbers). 862 * @return This object. 863 */ 864 public Input pattern(String value) { 865 attr("pattern", value); 866 return this; 867 } 868 869 /** 870 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-input-placeholder">placeholder</a> attribute. 871 * 872 * <p> 873 * Provides a hint to the user about what to enter in the input field. 874 * The placeholder text appears when the field is empty and disappears when the user starts typing. 875 * 876 * @param value Hint text to display in the empty input field. 877 * @return This object. 878 */ 879 public Input placeholder(String value) { 880 attr("placeholder", value); 881 return this; 882 } 883 884 /** 885 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-input-readonly">readonly</a> attribute. 886 * 887 * <p> 888 * Whether to allow the value to be edited by the user. 889 * 890 * @param value If <jk>true</jk>, adds <c>readonly="readonly"</c>. 891 * @return This object. 892 */ 893 public Input readonly(boolean value) { 894 if (value) 895 value("value"); 896 return this; 897 } 898 899 /** 900 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-input-readonly">readonly</a> attribute. 901 * 902 * <p> 903 * Makes the input field read-only, preventing user modification while still allowing 904 * the value to be submitted with the form. 905 * 906 * @param value If <jk>true</jk>, makes the input read-only. 907 * @return This object. 908 */ 909 public Input readonly(Object value) { 910 attr("readonly", value); 911 return this; 912 } 913 914 /** 915 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-input-readonly">required</a> attribute. 916 * 917 * <p> 918 * Indicates that the input field must be filled out before the form can be submitted. 919 * Browsers will show validation messages for empty required fields. 920 * 921 * @param value If <jk>true</jk>, makes the input required for form submission. 922 * @return This object. 923 */ 924 public Input required(Object value) { 925 attr("required", value); 926 return this; 927 } 928 929 /** 930 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-input-size">size</a> attribute. 931 * 932 * <p> 933 * Size of the control. 934 * 935 * @param value 936 * The new value for this attribute. 937 * Typically a {@link Number} or {@link String}. 938 * @return This object. 939 */ 940 public Input size(Object value) { 941 attr("size", value); 942 return this; 943 } 944 945 @Override /* Overridden from HtmlElement */ 946 public Input spellcheck(Object value) { 947 super.spellcheck(value); 948 return this; 949 } 950 951 /** 952 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-input-src">src</a> attribute. 953 * 954 * <p> 955 * Address of the resource. 956 * 957 * @param value 958 * The new value for this attribute. 959 * Typically a {@link URL} or {@link String}. 960 * @return This object. 961 */ 962 public Input src(Object value) { 963 attr("src", value); 964 return this; 965 } 966 967 /** 968 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-input-step">step</a> attribute. 969 * 970 * <p> 971 * Granularity to be matched by the form control's value. 972 * 973 * @param value The new value for this attribute. 974 * @return This object. 975 */ 976 public Input step(String value) { 977 attr("step", value); 978 return this; 979 } 980 981 @Override /* Overridden from HtmlElement */ 982 public Input style(String value) { 983 super.style(value); 984 return this; 985 } 986 987 @Override /* Overridden from HtmlElement */ 988 public Input tabindex(Object value) { 989 super.tabindex(value); 990 return this; 991 } 992 993 @Override /* Overridden from HtmlElement */ 994 public Input title(String value) { 995 super.title(value); 996 return this; 997 } 998 999 @Override /* Overridden from HtmlElement */ 1000 public Input translate(Object value) { 1001 super.translate(value); 1002 return this; 1003 } 1004 1005 /** 1006 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-input-type">type</a> attribute. 1007 * 1008 * <p> 1009 * Specifies the type of form control to display. 1010 * 1011 * <p> 1012 * Common values: 1013 * <ul> 1014 * <li><js>"text"</js> - Single-line text input (default)</li> 1015 * <li><js>"password"</js> - Password input (characters are masked)</li> 1016 * <li><js>"email"</js> - Email address input with validation</li> 1017 * <li><js>"number"</js> - Numeric input with spinner controls</li> 1018 * <li><js>"tel"</js> - Telephone number input</li> 1019 * <li><js>"url"</js> - URL input with validation</li> 1020 * <li><js>"search"</js> - Search input field</li> 1021 * <li><js>"date"</js> - Date picker</li> 1022 * <li><js>"time"</js> - Time picker</li> 1023 * <li><js>"datetime-local"</js> - Date and time picker</li> 1024 * <li><js>"checkbox"</js> - Checkbox input</li> 1025 * <li><js>"radio"</js> - Radio button input</li> 1026 * <li><js>"file"</js> - File upload input</li> 1027 * <li><js>"submit"</js> - Submit button</li> 1028 * <li><js>"button"</js> - Generic button</li> 1029 * <li><js>"reset"</js> - Reset form button</li> 1030 * <li><js>"hidden"</js> - Hidden input field</li> 1031 * </ul> 1032 * 1033 * @param value The input type for the form control. 1034 * @return This object. 1035 */ 1036 public Input type(String value) { 1037 attr("type", value); 1038 return this; 1039 } 1040 1041 /** 1042 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-input-value">value</a> attribute. 1043 * 1044 * <p> 1045 * Value of the form control. 1046 * 1047 * @param value 1048 * The new value for this attribute. 1049 * Typically a {@link Number} or {@link String}. 1050 * @return This object. 1051 */ 1052 public Input value(Object value) { 1053 attr("value", value); 1054 return this; 1055 } 1056 1057 /** 1058 * <a class="doclink" href="https://www.w3.org/TR/html5/embedded-content-0.html#attr-dim-width">width</a> attribute. 1059 * 1060 * <p> 1061 * Horizontal dimension. 1062 * 1063 * @param value 1064 * The new value for this attribute. 1065 * Typically a {@link Number} or {@link String}. 1066 * @return This object. 1067 */ 1068 public Input width(Object value) { 1069 attr("width", value); 1070 return this; 1071 } 1072}