Commit 2adebe2d119ec7f997d9eed14b3f302ba7a5181e
Exists in
master
and in
1 other branch
Merge branch 'master' into 'develop'
Master See merge request !26
Showing
2 changed files
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,9 @@ 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'); | |
500 | + return; | |
499 | 501 | } else if (!$scope.cliente.TEL) { |
500 | 502 | focaModalService.alert('Ingrese un numero de telefono'); |
501 | 503 | return; |
... | ... | @@ -631,6 +633,20 @@ angular.module('focaBusquedaCliente') |
631 | 633 | $scope.selectedClientes = 0; |
632 | 634 | } |
633 | 635 | } |
636 | + // | |
637 | + function validateEmails(emails) { | |
638 | + 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,}))$/; | |
639 | + var arr = emails.split(','); | |
640 | + var result = true; | |
641 | + | |
642 | + arr.forEach(function(email) { | |
643 | + var val = String(email).trim().toLowerCase(); | |
644 | + | |
645 | + if (!re.test(val)) result = false; | |
646 | + }); | |
647 | + | |
648 | + return result; | |
649 | + } | |
634 | 650 | |
635 | 651 | } |
636 | 652 | ]); |
src/views/foca-busqueda-cliente-modal.html