Advertisement
krot

mask validator phone

Feb 14th, 2019
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 0.82 KB | None | 0 0
  1. $('#orderFormPhone').mask('\+0(000)000-00-00');
  2. $('#orderFormName').mask("A", {
  3.     translation: {
  4.         "A": { pattern: /[a-zA-Z А-Яа-яёЁ]/, recursive: true }
  5.     }
  6. });
  7.  
  8. $('#orderFormCity').mask("A", {
  9.     translation: {
  10.         "A": { pattern: /[a-zA-Z А-Яа-яёЁ]/, recursive: true }
  11.     }
  12. });
  13. $('#orderFormEmail').mask("A", {
  14.     translation: {
  15.         "A": { pattern: /[\w@\-.+]/, recursive: true }
  16.     }
  17. });
  18. //doc mask -> http://igorescobar.github.io/jQuery-Mask-Plugin/docs.html
  19.  
  20. $('#orderFormEmail').on('blur', function () {
  21.   let email = $(this).val();
  22.  
  23.   if (email.length > 0
  24.   && (email.match(/.+?\@.+/g) || []).length !== 1) {
  25.     console.log('invalid');
  26.     alert('Вы ввели некорректный e-mail!');
  27.   } else {
  28.     console.log('valid');
  29.     alert('Вы ввели корректный e-mail!');
  30.   }
  31. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement