summaryrefslogtreecommitdiffstats
path: root/admin/WebConsole/jscripts
diff options
context:
space:
mode:
authordanigm <danigm@wadobo.com>2011-03-18 07:38:32 +0000
committerdanigm <danigm@wadobo.com>2011-03-18 07:38:32 +0000
commit008349f37090e5cd4fae7c3886d5ab90ee7d6dd6 (patch)
tree9553222ae2e94745997dd2f381dc0db3d1448ef6 /admin/WebConsole/jscripts
parentc9c86183187905f5ba92377173039de803f40509 (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/WebConsole/jscripts')
-rw-r--r--admin/WebConsole/jscripts/propiedades_aulas.js26
-rw-r--r--admin/WebConsole/jscripts/validators.js49
2 files changed, 65 insertions, 10 deletions
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";
+}