diff options
author | danigm <danigm@wadobo.com> | 2011-03-18 07:38:32 +0000 |
---|---|---|
committer | danigm <danigm@wadobo.com> | 2011-03-18 07:38:32 +0000 |
commit | 008349f37090e5cd4fae7c3886d5ab90ee7d6dd6 (patch) | |
tree | 9553222ae2e94745997dd2f381dc0db3d1448ef6 /admin | |
parent | c9c86183187905f5ba92377173039de803f40509 (diff) |
Validación de propiedades de aulas, añadida validación de velocidad de multicast
git-svn-id: https://opengnsys.es/svn/branches/version1.0@1559 a21b9725-9963-47de-94b9-378ad31fedc9
Diffstat (limited to 'admin')
5 files changed, 68 insertions, 10 deletions
diff --git a/admin/WebConsole/idiomas/javascripts/eng/propiedades_aulas_eng.js b/admin/WebConsole/idiomas/javascripts/eng/propiedades_aulas_eng.js index d49c7db6..fa7b8bfc 100644 --- a/admin/WebConsole/idiomas/javascripts/eng/propiedades_aulas_eng.js +++ b/admin/WebConsole/idiomas/javascripts/eng/propiedades_aulas_eng.js @@ -8,4 +8,5 @@ TbMsg[0]="You must introduce a name for this lab"; TbMsg[1]="You must introduce a number of places for this lab"; TbMsg[2]="WARNING.- This lab contain others groups or labs. If you remove it, you will also remove all these. ¿ Are you sure ?"; TbMsg[3]="Time for begining of reserves periode must be smaller than final time"; +TbMsg[4]="Multicast speed is not valid, use numbers only"; diff --git a/admin/WebConsole/idiomas/javascripts/esp/propiedades_aulas_esp.js b/admin/WebConsole/idiomas/javascripts/esp/propiedades_aulas_esp.js index 4c4dcaea..b1d2f93c 100644 --- a/admin/WebConsole/idiomas/javascripts/esp/propiedades_aulas_esp.js +++ b/admin/WebConsole/idiomas/javascripts/esp/propiedades_aulas_esp.js @@ -8,4 +8,5 @@ TbMsg[0]="Debe introducir un nombre para este aula"; TbMsg[1]="Debe introducir un número de puestos para este aula"; TbMsg[2]="ATENCIÓN.- Este aula contiene grupos de ordenadores u ordenadores. Si los elimina, eliminará también éstos. ¿ Está seguro ?"; TbMsg[3]="La hora de comienzo del intervalo de reservas debe ser menor que la hora final"; +TbMsg[4]="La velocidad de multicast no es válida, sólo números"; diff --git a/admin/WebConsole/jscripts/propiedades_aulas.js b/admin/WebConsole/jscripts/propiedades_aulas.js index 0d37ec12..86b13256 100644 --- a/admin/WebConsole/jscripts/propiedades_aulas.js +++ b/admin/WebConsole/jscripts/propiedades_aulas.js @@ -84,24 +84,30 @@ function confirmar(op){ // Comprobar_datos //________________________________________________________________________________________________________ function comprobar_datos(){ - if (document.fdatos.nombreaula.value=="") { - alert(TbMsg[0]); - document.fdatos.nombreaula.focus(); - return(false); - } - if (document.fdatos.puestos.value=="" || document.fdatos.puestos.value=="0") { - alert(TbMsg[1]); - document.fdatos.puestos.focus(); - return(false); + function validate (field, validator, msgi) { + if (!validator (field.value)) { + alert(TbMsg[msgi]); + validation_highlight (field); + return false; + } + return true; } + if (parseInt(document.fdatos.horaresevini.value)>parseInt(document.fdatos.horaresevfin.value)) { alert(TbMsg[3]); - document.fdatos.horaresevini.focus(); + validation_highlight (document.fdatos.horaresevini); + validation_highlight (document.fdatos.horaresevfin); return(false); } + var form = document.fdatos; + return validate (form.nombreaula, validate_notnull, 0) && + validate (form.puestos, validate_notnull, 1) && + validate (form.velmul, validate_number, 4); + return(true); } + //________________________________________________________________________________________________________ function vertabla_horas(ohora){ currentHora=ohora; diff --git a/admin/WebConsole/jscripts/validators.js b/admin/WebConsole/jscripts/validators.js new file mode 100644 index 00000000..d9afb0f0 --- /dev/null +++ b/admin/WebConsole/jscripts/validators.js @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2011 Daniel Garcia <danigm@wadobo.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + + +function validate_expr(value, epx) { + var expr = new RegExp(epx); + return (value.search(expr) == 0); +} + +function validate_number(value) { + return validate_expr(value, "^\d*$"); +} + +function validate_alphanum(value) { + return validate_expr(value, "^\w*$"); +} + +function validate_notnull(value) { + return validate_expr(value, "^.+$") && !validate_expr(value, "^\s*0\s*$"); +} + +function validate_number_notnull(value) { + return validate_number(value) && validate_notnull(value); +} + +function validate_alphanum_notnull(value) { + return validate_number(value) && validate_notnull(value); +} + +function validation_highlight(field) { + field.focus(); + field.style.border = "1px solid red"; + field.style.background = "#fee"; +} diff --git a/admin/WebConsole/propiedades/propiedades_aulas.php b/admin/WebConsole/propiedades/propiedades_aulas.php index afd914dd..31cfa8df 100644 --- a/admin/WebConsole/propiedades/propiedades_aulas.php +++ b/admin/WebConsole/propiedades/propiedades_aulas.php @@ -47,6 +47,7 @@ else <HEAD> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <LINK rel="stylesheet" type="text/css" href="../estilos.css"> + <SCRIPT language="javascript" src="../jscripts/validators.js"></SCRIPT> <SCRIPT language="javascript" src="../jscripts/propiedades_aulas.js"></SCRIPT> <SCRIPT language="javascript" src="../jscripts/opciones.js"></SCRIPT> <? echo '<SCRIPT language="javascript" src="../idiomas/javascripts/'.$idioma.'/propiedades_aulas_'.$idioma.'.js"></SCRIPT>'?> |