Custom Form Validation Magento2

Custom Form Validation Magento2

<script type=”text/x-magento-init”>
{
“#custom-form-id-new”: {
“validation”: {}
}
}
</script>

 

<form id=”custom-form-id-new” action=”” method=””>

<input data-validate='{“required”:true}’ width=”200″ type=”text” placeholder=”Name” name=”name”>
<input data-validate=”{required:true, ‘validate-email’:true}” type=”text” placeholder=”Email” name=”email”>
</form>

Magento rules:

  1. max-words
  2. min-words
  3. range-words
  4. letters-with-basic-punc
  5. alphanumeric
  6. letters-only
  7. no-whitespace
  8. zip-range
  9. integer
  10. vinUS
  11. dateITA
  12. dateNL
  13. time
  14. time12h
  15. phoneUS
  16. phoneUK
  17. mobileUK
  18. stripped-min-length
  19. email2
  20. url2
  21. credit-card-types
  22. ipv4
  23. ipv6
  24. pattern
  25. allow-container-className
  26. validate-no-html-tags
  27. validate-select
  28. validate-no-empty
  29. validate-alphanum-with-spaces
  30. validate-data
  31. validate-street
  32. validate-phoneStrict
  33. validate-phoneLax
  34. validate-fax
  35. validate-email
  36. validate-emailSender
  37. validate-password
  38. validate-admin-password
  39. validate-customer-password
  40. validate-url
  41. validate-clean-url
  42. validate-xml-identifier
  43. validate-ssn
  44. validate-zip-us
  45. validate-date-au
  46. validate-currency-dollar
  47. validate-not-negative-number
  48. validate-zero-or-greater
  49. validate-greater-than-zero
  50. validate-css-length
  51. validate-number
  52. required-number
  53. validate-number-range
  54. validate-digits
  55. validate-digits-range
  56. validate-range
  57. validate-alpha
  58. validate-code
  59. validate-alphanum
  60. validate-date
  61. validate-date-range
  62. validate-cpassword
  63. validate-identifier
  64. validate-zip-international
  65. validate-one-required
  66. validate-state
  67. required-file
  68. validate-ajax-error
  69. validate-optional-datetime
  70. validate-required-datetime
  71. validate-one-required-by-name
  72. less-than-equals-to
  73. greater-than-equals-to
  74. validate-emails
  75. validate-cc-type-select
  76. validate-cc-number
  77. validate-cc-type
  78. validate-cc-exp
  79. validate-cc-cvn
  80. validate-cc-ukss
  81. validate-length
  82. required-entry
  83. not-negative-amount
  84. validate-per-page-value-list
  85. validate-per-page-value
  86. validate-new-password
  87. required-if-not-specified
  88. required-if-all-sku-empty-and-file-not-loaded
  89. required-if-specified
  90. required-number-if-specified
  91. datetime-validation
  92. required-text-swatch-entry
  93. required-visual-swatch-entry
  94. required-dropdown-attribute-entry
  95. Validate-item-quantity
  96. validate-grouped-qty
  97. validate-one-checkbox-required-by-name
  98. validate-date-between
  99. validate-dob