You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

100 lines
4.0 KiB

4 years ago
  1. +++
  2. title = "Form"
  3. description = "Collect, validate and handle user input."
  4. categories = ["experience"]
  5. tags = ["controls"]
  6. html_attributes = ["id", "name", "accept-charset", "action", "enctype", "target", "novalidate", "method", "class", "autocomplete"]
  7. custom_attributes = []
  8. snippets_used = ["help block", "button", "alert", "throbber", "label", "form group", "form", "text input"]
  9. [[copyright]]
  10. owner = "Josh Habdas"
  11. date = "2019"
  12. license = "agpl-3.0-or-later"
  13. +++
  14. With auto-focused [Text Input](../text-input) requesting a new email address:
  15. ```html
  16. {{</* hackcss-form autocomplete="disabled" >}}
  17. {{< hackcss-textinput autofocus="true" type="email" placeholder="Please change your email…" >}}
  18. {{< /hackcss-form */>}}
  19. ```
  20. {{< hackcss-form autocomplete="disabled" >}}
  21. {{< hackcss-textinput autofocus="true" type="email" placeholder="Please change your email…" >}}
  22. {{< /hackcss-form >}}
  23. With [Text Input](../text-input) and [Label](../label) inside [Form Group](../form-group) running [Fuzzy Search](/feature/fuzzy-search) in new window:
  24. ```html
  25. {{</* hackcss-form id="search" action="/search/" target="_blank" */>}}
  26. {{</* hackcss-formgroup >}}
  27. {{< hackcss-label for="query" text="Search query:" />}}
  28. {{< hackcss-textinput id="query" type="search" name="s" form="search" >}}
  29. {{< /hackcss-formgroup */>}}
  30. ```
  31. {{< hackcss-form id="search" action="/search" target="_blank" />}}
  32. {{< hackcss-formgroup >}}
  33. {{< hackcss-label for="query" text="Search query:" />}}
  34. {{< hackcss-textinput id="query" type="search" name="s" form="search" >}}
  35. {{< /hackcss-formgroup >}}
  36. Two forms with a [Button](../button) and [Text Input](../text-input) inside [Alert](../alert) with [Throbber](../throbber):
  37. ```html
  38. {{</* hackcss-alert type="info" >}}
  39. {{< hackcss-form id="throttle" method="post" action="/throttle" />}}
  40. {{< hackcss-form id="choke" novalidate="true" />}}
  41. {{< hackcss-button type="primary" form="choke" text="Doh!" disabled="true" />}}
  42. This one doesn't actually do anything… {{< hackcss-throbber >}}
  43. {{< hackcss-textinput type="hidden" name="speed" value="80" form="throttle" >}}
  44. {{< /hackcss-alert */>}}
  45. ```
  46. {{< hackcss-alert type="info" >}}
  47. {{< hackcss-form id="throttle" method="post" action="/throttle" />}}
  48. {{< hackcss-form id="choke" novalidate="true" />}}
  49. {{< hackcss-button type="primary" form="choke" text="Doh!" disabled="true" />}}
  50. This one doesn't actually do anything… {{< hackcss-throbber >}}
  51. {{< hackcss-textinput type="hidden" name="speed" value="80" form="throttle" >}}
  52. {{< /hackcss-alert >}}
  53. With [Form Group](../form-group), [Label](../label), required and validated [Text Input](../text-input) and [Help Block](../help-block):
  54. ```html
  55. {{</* hackcss-form name="validate" action="/validate" >}}
  56. {{< hackcss-formgroup name="integrity" >}}
  57. {{< hackcss-label for="digest" >}}
  58. <abbr title="Secure Hash Algorithm">SHA-512</abbr> Digest:
  59. {{< /hackcss-label >}}
  60. {{< hackcss-textinput
  61. required="true"
  62. autofocus="true"
  63. autocomplete="off"
  64. type="text" id="digest" name="digest"
  65. pattern="^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$" >}}
  66. {{< hackcss-helpblock >}}
  67. Submit with digest to validate installation.
  68. <noscript>JavaScript must be enabled for proper validation.</noscript>
  69. {{< /hackcss-helpblock >}}
  70. {{< /hackcss-formgroup >}}
  71. {{< /hackcss-form */>}}
  72. ```
  73. {{< hackcss-form name="validate" action="/validate" >}}
  74. {{< hackcss-formgroup name="integrity" >}}
  75. {{< hackcss-label for="digest" >}}
  76. <abbr title="Secure Hash Algorithm">SHA-512</abbr> Digest:
  77. {{< /hackcss-label >}}
  78. {{< hackcss-textinput
  79. required="true"
  80. autocomplete="off"
  81. type="text" id="digest" name="digest"
  82. pattern="^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$" >}}
  83. {{< hackcss-helpblock >}}
  84. Submit with digest to validate installation.
  85. <noscript>JavaScript must be enabled for proper validation.</noscript>
  86. {{< /hackcss-helpblock >}}
  87. {{< /hackcss-formgroup >}}
  88. {{< /hackcss-form >}}