Advertisement
Dimalolzet

aquamarin_inputs-validation

May 17th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. bindInputsValidation = function() {
  2.     'use strict';
  3.     var $emailInput, $phoneInput, invalidClass, isEmail;
  4.     $phoneInput = $(".input[type='tel']");
  5.     $emailInput = $(".input[type='email']");
  6.     invalidClass = 'input-wrapper_invalid';
  7.     isEmail = function(email) {
  8.         return !!email.match(/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i);
  9.     };
  10.     $emailInput.blur(function() {
  11.         var value;
  12.         value = $(this).val();
  13.         if (!isEmail(value) && value !== '') {
  14.             return $(this).parent().addClass(invalidClass);
  15.         }
  16.     });
  17.     $('.input').focus(function() {
  18.         return $(this).parent().removeClass(invalidClass);
  19.     });
  20.     return $phoneInput.mask("+375 (99) 999-99-99");
  21. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement