Программы [Boris] Validation script. Лёгкий в понимании!

M

Moderator

#1


Validation
Using

Required attribute [data-check] in the block for the validation element.
This attribute has 2 parameters.
Parameters write through the separator '|'.
  1. Type of element for validation ('input' or 'select').
  2. Mode for show error:
    'mode-1': Class 'error-validation' is added for 1.5 seconds.
    'mode-2': Show error message.
Example attribute [data-check]: data-check="input|mode-1".

If the element for validation is an input, then we add attribute [data-input-check] to it.
Parameters for this attribute are optional.
Parameters write through the separator '|'.
  1. "required" - Field is required.
  2. "number" - Only integer.
  3. "num:5<>12" - Only integer and length 5 - 12.
  4. "mail" - Only email address.
  5. "min:5" - Length min 5.
  6. "max:12" - Length max 12.
  7. "allow:[A-z]" - RegExp.
  8. "phone" - Only phone.
  9. "password_confirmation" - For password confirmation.
Example attribute [data-input-check]: data-input-check="required|email".

If you want to add validation in your script, just add:
if( validation() ) { ...code }

To add automatic validation to the form, add the [data-validation-form] attribute:
<form action="#" data-validation-form> ... </form>

Example using all validation - index.html

Достаточно лишь добавить атрибут к элементу валидации (input or select)!

Подключите <script src="validation.js"></script>

Пример:

|
Посмотреть вложение 45955
 
Get involved!

Here you can only see a limited number of comments. On KursStore.com - Слив курсов – скачать слитые курсы бесплатно! you see all comments and all functions are available to you. To the thread