Commit 2d1ef9bd2171ae63efe0d9ebc52ed259d8e8ddef
1 parent
76ce8a7919
Exists in
master
and in
1 other branch
Validacion de formato email - Arreglo de tipeo con Teclado Virtual
Showing
2 changed files
with
17 additions
and
2 deletions
Show diff stats
src/js/controller.js
... | ... | @@ -463,7 +463,6 @@ angular.module('focaBusquedaCliente') |
463 | 463 | }; |
464 | 464 | |
465 | 465 | $scope.pasarCampoCuit = function(numeroCuit) { |
466 | - | |
467 | 466 | if (numeroCuit === 1 && $scope.cliente.cuit1.length === 2) { |
468 | 467 | $scope.cuitActivo = 2; |
469 | 468 | } else if ( numeroCuit === 2 && $scope.cliente.cuit2.length === 8) { |
... | ... | @@ -496,6 +495,8 @@ angular.module('focaBusquedaCliente') |
496 | 495 | } else if (!$scope.cliente.cobrador.NUM) { |
497 | 496 | focaModalService.alert('Seleccione un cobrador'); |
498 | 497 | return; |
498 | + } else if ($scope.cliente.MAIL && !validateEmails($scope.cliente.MAIL)) { | |
499 | + focaModalService.alert('Ingrese un formato de email válido') | |
499 | 500 | } else if (!$scope.cliente.TEL) { |
500 | 501 | focaModalService.alert('Ingrese un numero de telefono'); |
501 | 502 | return; |
... | ... | @@ -631,6 +632,20 @@ angular.module('focaBusquedaCliente') |
631 | 632 | $scope.selectedClientes = 0; |
632 | 633 | } |
633 | 634 | } |
635 | + // | |
636 | + function validateEmails(emails) { | |
637 | + var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; | |
638 | + var arr = emails.split(','); | |
639 | + var result = true; | |
640 | + | |
641 | + arr.forEach(function(email) { | |
642 | + var val = String(email).trim().toLowerCase(); | |
643 | + | |
644 | + if (!re.test(val)) result = false; | |
645 | + }); | |
646 | + | |
647 | + return result; | |
648 | + } | |
634 | 649 | |
635 | 650 | } |
636 | 651 | ]); |
src/views/foca-busqueda-cliente-modal.html