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

  • Автор темы Boris_Nex
  • Дата начала

Boris_Nex

Премиум
Регистрация
26 Ноя 2018
Сообщения
2
Лайки
662
Монетки
336
Голосов: 0
0.0 5 0 0 https://sharewood.bizhttps://sharewood.biz/threads/boris-validation-script-%D0%9B%D1%91%D0%B3%D0%BA%D0%B8%D0%B9-%D0%B2-%D0%BF%D0%BE%D0%BD%D0%B8%D0%BC%D0%B0%D0%BD%D0%B8%D0%B8.55184/
#1
Автор: Boris
Название: Validation script. Лёгкий в понимании!

proxy.php?image=https%3A%2F%2Fdmitro.pro%2Fwp-content%2Fuploads%2F2018%2F03%2Fjs-logo.png&hash=42c380d9cd0298f4b13fb12c27e83397

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>

Пример:

|
%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA-%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0-2019-11-06-%D0%B2-12-20-12-png.45955


Скачать:
 
Последнее редактирование:
Сверху Снизу