pablocattaneo
5/20/2017 - 2:29 PM

Validation forms Magento 2. !imortant Si los inputs no tienen name, magento sólo valida el primer input del form que tenga una clase para v

Validation forms Magento 2. !imortant Si los inputs no tienen name, magento sólo valida el primer input del form que tenga una clase para validar.

Source: https://magento.stackexchange.com/questions/95171/magento-2-form-validation

Important!!

Si los inputs no tienen name, magento sólo valida el primer input del form que tenga una clase para validar.

This are validations rules, use it like a css class inside de input to validate. 

For example

<input type="text" value="" class=" required-entry">


min_text_length
max_text_length
max-words
min-words
range-words
letters-with-basic-punc
alphanumeric
letters-only
no-whitespace
zip-range
integer
vinUS
dateITA
dateNL
time
time12h
phoneUS
phoneUK
mobileUK
stripped-min-length
email2
url2
credit-card-types
ipv4
ipv6
pattern
validate-no-html-tags
validate-select
validate-no-empty
validate-alphanum-with-spaces
validate-data
validate-street
validate-phoneStrict
validate-phoneLax
validate-fax
validate-email
validate-emailSender
validate-password
validate-admin-password
validate-url
validate-clean-url
validate-xml-identifier
validate-ssn
validate-zip-us
validate-date-au
validate-currency-dollar
validate-not-negative-number
validate-zero-or-greater
validate-greater-than-zero
validate-css-length
validate-number
validate-number-range
validate-digits
validate-digits-range
validate-range
validate-alpha
validate-code
validate-alphanum
validate-date
validate-identifier
validate-zip-international
validate-state
less-than-equals-to
greater-than-equals-to
validate-emails
validate-cc-number
validate-cc-ukss
required-entry
checked
not-negative-amount
validate-per-page-value-list
validate-new-password
validate-item-quantity
equalTo
<form id="form-to-validate">
    <input type="text" id="origin" name="origin" value="" title="Desde" class="input-text required-entry">
    <button type="submit" class="button" title="Buscar">Buscar</button>
</form>

<script type="text/x-magento-init">
    {
        "#form-to-validate": {
            "validation": {}
        }
    }
</script>