Commit 5ca418f1772fc520b77f319689a007fe24bca343

Authored by Luis Suarez
1 parent b8454e1414
Exists in develop

validar nombre, tlf y DNI

src/js/controller.js
... ... @@ -67,8 +67,11 @@ angular.module('focaAbmChofer')
67 67 } else if (!chofer.idTipoDocumento) {
68 68 focaModalService.alert('Ingrese tipo documento');
69 69 return;
70   - }
  70 + } else if (!/^([\d]{7,10})$/.test(chofer.telefono)) {
  71 + focaModalService.alert('El campo Teléfono debe tener de 7 a 10 digitos');
  72 + }
71 73 validaDni(chofer);
  74 + console.log('Todo ok, guardar chofer');
72 75 };
73 76  
74 77 $scope.tipoDocumento = function (idTipoDocumento) {
... ... @@ -218,5 +221,18 @@ angular.module('focaAbmChofer')
218 221 if (!chofer.id) { chofer.id = 0; }
219 222 $location.path('/chofer/' + chofer.id + '/' + chofer.idTransportista);
220 223 }
  224 +
  225 + $scope.validarDatosChofer = function() {
  226 + // No permito numero ni caracteres especiles en nombre de chofer
  227 + if (!/^([a-zA-ZÀ-ÿ ])*$/.test($scope.chofer.nombre)) {
  228 + focaModalService.alert('el campo Nombre no debe incluir números o símbolos')
  229 + $scope.chofer.nombre = ''
  230 + }
  231 + // Solo numeros en el campo documento
  232 + if (!/^([0-9])*$/.test($scope.chofer.dni)) {
  233 + focaModalService.alert('el campo DNI solo puede incluir números')
  234 + $scope.chofer.dni = ''
  235 + }
  236 + }
221 237 }
222 238 ]);
src/views/foca-abm-choferes-listado.html
... ... @@ -39,6 +39,7 @@
39 39 type="text"
40 40 teclado-virtual
41 41 ng-model="chofer.nombre"
  42 + ng-keyup="validarDatosChofer()"
42 43 ng-required="true"
43 44 ng-keypress="next($event.keyCode)"
44 45 foca-focus="focused == 1"
... ... @@ -60,8 +61,11 @@
60 61 foca-tipo-input
61 62 teclado-virtual
62 63 solo-positivos
63   - limite-numeros-max="15"
  64 + limite-numeros-max="12"
  65 + maxlength="12"
  66 + minlength="2"
64 67 ng-model="chofer.dni"
  68 + ng-keyup="validarDatosChofer()"
65 69 ng-required="true"
66 70 ng-keypress="next($event.keyCode)"
67 71 foca-focus="focused == 2"
... ... @@ -76,7 +80,8 @@
76 80 foca-tipo-input
77 81 teclado-virtual
78 82 solo-positivos
79   - limite-numeros-max="15"
  83 + limite-numeros-max="10"
  84 + maxlength="10"
80 85 ng-model="chofer.telefono"
81 86 ng-required="true"
82 87 foca-focus="focused == 3"