summaryrefslogtreecommitdiffstats
path: root/admin/WebConsole/jscripts
diff options
context:
space:
mode:
authorramon <ramongomez@us.es>2013-04-09 12:59:23 +0000
committerramon <ramongomez@us.es>2013-04-09 12:59:23 +0000
commitc78cd32709a2efaf3e5d488147be85f62de50544 (patch)
tree14bb96289e5ed424ad0b17cbe0f1a3649d78c783 /admin/WebConsole/jscripts
parent121946bca95b039d20f49eba6b0f21758ea24342 (diff)
#452 #585: Mejorar la validación de datos en formulario de propiedades de aulas:
* Comprobar direcciones IP (en general). * Comprobar URL (nueva). * Comprobar consistencia en datos de validación (solo este formulario). git-svn-id: https://opengnsys.es/svn/branches/version1.0@3737 a21b9725-9963-47de-94b9-378ad31fedc9
Diffstat (limited to 'admin/WebConsole/jscripts')
-rw-r--r--admin/WebConsole/jscripts/propiedades_aulas.js24
-rw-r--r--admin/WebConsole/jscripts/validators.js26
2 files changed, 41 insertions, 9 deletions
diff --git a/admin/WebConsole/jscripts/propiedades_aulas.js b/admin/WebConsole/jscripts/propiedades_aulas.js
index 61126a6f..947ab1d5 100644
--- a/admin/WebConsole/jscripts/propiedades_aulas.js
+++ b/admin/WebConsole/jscripts/propiedades_aulas.js
@@ -93,26 +93,36 @@ function comprobar_datos(){
return true;
}
+/* HORA DE RESERVA TEMPORALMENTE DESHABILITADA.
if (parseInt(document.fdatos.horaresevini.value)>parseInt(document.fdatos.horaresevfin.value)) {
alert(TbMsg[3]);
validation_highlight (document.fdatos.horaresevini);
validation_highlight (document.fdatos.horaresevfin);
return(false);
}
+*/
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[14]);
+ validation_highlight (document.fdatos.paginalogin);
+ validation_highlight (document.fdatos.paginavalidacion);
+ return(false);
+ }
+ // Validación general de datos del formulario.
return validate (form.nombreaula, validate_notnull, 0) &&
validate (form.puestos, validate_number_notnull, 1) &&
validate (form.router, validate_ipadress_notnull, 4) &&
- validate (form.netmask, validate_ipadress_notnull, 5) &&
+ validate (form.netmask, validate_ipadress_notnull, 5) &&
+ validate (form.dns, validate_ipadress, 12) &&
+ validate (form.proxy, validate_url, 13) &&
validate (form.modp2p, validate_notnull, 6) &&
- validate (form.timep2p, validate_number_notnull, 7) &&
- validate (form.modomul, validate_notnull, 8) &&
- validate (form.ipmul, validate_ipadress_notnull, 9) &&
- validate (form.pormul, validate_notnull, 10) &&
+ validate (form.timep2p, validate_number_notnull, 7) &&
+ validate (form.modomul, validate_notnull, 8) &&
+ validate (form.ipmul, validate_ipadress_notnull, 9) &&
+ validate (form.pormul, validate_notnull, 10) &&
validate (form.velmul, validate_number_notnull, 11);
-
- return(true);
}
//________________________________________________________________________________________________________
diff --git a/admin/WebConsole/jscripts/validators.js b/admin/WebConsole/jscripts/validators.js
index e0359505..11ace4dc 100644
--- a/admin/WebConsole/jscripts/validators.js
+++ b/admin/WebConsole/jscripts/validators.js
@@ -17,11 +17,18 @@
*/
+// Validar expresión regular.
function validate_expr(value, epx) {
var expr = new RegExp(epx);
return (value.search(expr) == 0);
}
+// Validar expresión ignorando diferencias entre mayúsculas y minúsculas.
+function validate_expr_nocase(value, epx) {
+ var expr = new RegExp(epx, "i");
+ return (value.search(expr) == 0);
+}
+
function validate_number(value) {
return validate_expr(value, "^\\d*$");
}
@@ -42,15 +49,29 @@ function validate_alphanum_notnull(value) {
return validate_number(value) && validate_notnull(value);
}
-
+// Validar dirección IPv4.
function validate_ipadress(value) {
- return validate_expr(value, "^\\d+\\.\\d+\.\\d+\\.\\d+$");
+ var octet = '(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])';
+ var regex = '^((?:' + octet + '\\.){3}' + octet + ')?$';
+ return validate_expr(value, regex);
}
function validate_ipadress_notnull(value) {
return validate_ipadress(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])';
+ var regex = '^((ht|f)tps?:\/\/(([a-z0-9]+([\.\-a-z0-9]+)?\.[a-z]{2,5})|((' + octet + '\\.){3}' + octet + '))(:[0-9]{2,5})?(\/.*)?)?$';
+ return validate_expr_nocase(value, regex);
+
+}
+
+function validate_url_notnull(value) {
+ return validate_url(value) && validate_notnull(value);
+}
+
function validate_nameimagefile(value) {
return validate_expr(value, "^[0-9a-zA-Z]*$");
}
@@ -61,3 +82,4 @@ function validation_highlight(field) {
field.style.border = "1px solid red";
field.style.background = "#fee";
}
+