diff options
author | irina <irinagomez@us.es> | 2014-04-07 12:43:29 +0000 |
---|---|---|
committer | irina <irinagomez@us.es> | 2014-04-07 12:43:29 +0000 |
commit | 2772884c6fe3794db594327c1b24a9e44143c518 (patch) | |
tree | 2b11e6d7411cab0ba2f5061f7f946db603a96ca1 /admin/WebConsole/jscripts | |
parent | 87a78ad661189b321ece3c8a25073cb71c58de9e (diff) |
#643 Se mejora la validaciĆ³n del formulario de propiedades del ordenador
git-svn-id: https://opengnsys.es/svn/branches/version1.0@4223 a21b9725-9963-47de-94b9-378ad31fedc9
Diffstat (limited to 'admin/WebConsole/jscripts')
-rw-r--r-- | admin/WebConsole/jscripts/propiedades_ordenadores.js | 42 | ||||
-rw-r--r-- | admin/WebConsole/jscripts/validators.js | 10 |
2 files changed, 31 insertions, 21 deletions
diff --git a/admin/WebConsole/jscripts/propiedades_ordenadores.js b/admin/WebConsole/jscripts/propiedades_ordenadores.js index 22de9adf..21482f8f 100644 --- a/admin/WebConsole/jscripts/propiedades_ordenadores.js +++ b/admin/WebConsole/jscripts/propiedades_ordenadores.js @@ -74,26 +74,26 @@ function confirmar(op){ // Comprobar_datos //________________________________________________________________________________________________________ function comprobar_datos(){ - if (document.fdatos.nombreordenador.value=="") { - alert(TbMsg[0]); - document.fdatos.nombreordenador.focus(); - return(false); + function validate (field, validator, msgi) { + if (!validator (field.value)) { + alert(TbMsg[msgi]); + validation_highlight (field); + return false; + } + return true; } - if (document.fdatos.ip.value=="") { - alert(TbMsg[1]); - document.fdatos.ip.focus(); - return(false); - } - if (document.fdatos.mac.value=="") { - alert(TbMsg[2]); - document.fdatos.mac.focus(); - return(false); - } - var p=document.fdatos.idrepositorio.selectedIndex - if (p==0){ - alert(TbMsg[5]) - document.forms.fdatos.idrepositorio.focus() - return(false) - } - return(true); + + var form = document.fdatos; + // Si se activa la validaciĆ³n, comprobar que se incluyen los datos adecuados. + if (form.validacion.options[form.validacion.selectedIndex].value == 1 && (form.paginalogin.value == '' || form.paginavalidacion.value == '')) { + alert(TbMsg[6]); + validation_highlight (document.fdatos.paginalogin); + validation_highlight (document.fdatos.paginavalidacion); + return(false); + } + + return validate (form.nombreordenador, validate_notnull, 0) && + validate (form.ip, validate_ipadress_notnull, 1) && + validate (form.mac, validate_macaddress_notnull, 2) && + validate (form.idrepositorio, validate_number_notnull, 5) ; } diff --git a/admin/WebConsole/jscripts/validators.js b/admin/WebConsole/jscripts/validators.js index 11ace4dc..b4f40801 100644 --- a/admin/WebConsole/jscripts/validators.js +++ b/admin/WebConsole/jscripts/validators.js @@ -60,6 +60,16 @@ function validate_ipadress_notnull(value) { return validate_ipadress(value) && validate_notnull(value); } +// Validar direccion MAC +function validate_macaddress(value) { + var regex = '^([0-9a-fA-F]){12}$' + return validate_expr(value, regex); +} + +function validate_macaddress_notnull(value) { + return validate_macaddress(value) && validate_notnull(value); +} + // Validar URL. function validate_url(value) { var octet = '(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])'; |