[Koha-cvs] koha/koha-tmpl/intranet-tmpl/prog/en/includes/j... [rel_3_0]

Antoine Farnault antoine at koha-fr.org
Mon Jan 29 17:32:20 CET 2007


CVSROOT:	/sources/koha
Module name:	koha
Branch:		rel_3_0
Changes by:	Antoine Farnault <toins>	07/01/29 16:32:20

Modified files:
	koha-tmpl/intranet-tmpl/prog/en/includes/javascript: members.js 

Log message:
	fix some bugs on CheckDate & dopopguarantor

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/koha-tmpl/intranet-tmpl/prog/en/includes/javascript/members.js?cvsroot=koha&only_with_tag=rel_3_0&r1=1.4.2.5&r2=1.4.2.6

Patches:
Index: members.js
===================================================================
RCS file: /sources/koha/koha/koha-tmpl/intranet-tmpl/prog/en/includes/javascript/members.js,v
retrieving revision 1.4.2.5
retrieving revision 1.4.2.6
diff -u -b -r1.4.2.5 -r1.4.2.6
--- members.js	6 Dec 2006 10:23:11 -0000	1.4.2.5
+++ members.js	29 Jan 2007 16:32:20 -0000	1.4.2.6
@@ -6,36 +6,48 @@
  */
 function _(s) { return s; }
 
-function CheckDate(d) {
-if (d!="")
-{
-       // Cette fonction vérifie le format JJ/MM/AAAA saisi et la validité de la date.
-      // Le séparateur est défini dans la variable separateur
-      var amin=1900; // année mini
-      var amax=2100; // année maxi
-      var separateur="/"; // separateur entre jour/mois/annee
-      var j=(d.substring(0,2));
-      var m=(d.substring(3,5));
-      var a=(d.substring(6));
+function CheckDate(field) {
+var d = field.value;
+if (d!="") {
+       // this function checks id date is like JJ/MM/AAAA
+      var amin = 1900; // année mini
+      var amax = 2100; // année maxi
+      
+      var date = d.split("/");
+      
       var ok=1;
       var msg; 
-       if ( ((isNaN(j))||(j<1)||(j>31)) && (ok==1) ) {
-        msg = ("day not correct."); 
-	alert(msg); ok=0;
-      }
-      if ( ((isNaN(m))||(m<1)||(m>12)) && (ok==1) ) {
-        msg = ("month not correct.");
-	 alert(msg); ok=0;
-      }
-      if ( ((isNaN(a))||(a<amin)||(a>amax)) && (ok==1) ) {
-         msg =("years not correct."); 
-	alert(msg); ok=0;
-      }
-      if ( ((d.substring(2,3)!=separateur)||(d.substring(5,6)!=separateur)) && (ok==1) ) {
-        msg = ("Separator must be "+separateur); 
-	alert(msg); ok=0;
-      }
 
+      if ( (date.length < 2) && (ok==1) ) {
+        msg = _("Separator must be /"); 
+    	alert(msg); ok=0; field.focus();
+    	return;
+      }
+      
+      var dd   = date[0];
+      var mm   = date[1];
+      var yyyy = date[2]; 
+      
+      // checking days
+      if ( ((isNaN(dd))||(dd<1)||(dd>31)) && (ok==1) ) {
+        msg = _("day not correct."); 
+	    alert(msg); ok=0; field.focus();
+	    return;
+      }
+      
+      // checking months
+      if ( ((isNaN(mm))||(mm<1)||(mm>12)) && (ok==1) ) {
+        msg = _("month not correct.");
+	    alert(msg); ok=0; field.focus();
+	    return;
+      }
+      
+      // checking years
+      if ( ((isNaN(yyyy))||(yyyy<amin)||(yyyy>amax)) && (ok==1) ) {
+         msg = _("years not correct."); 
+	    alert(msg); ok=0; field.focus();
+	    return;
+      }
    }
 }
 
@@ -103,7 +115,6 @@
  	} 
 	document.form.submit();
 	
-
 } else {
 	if (document.form.BorrowerMandatoryField.value==''||document.form.FormFieldList.value=='' )
 	{}
@@ -126,7 +137,7 @@
 							if (ref_champ.options[0].selected ){
 								// action if field is empty
 								message_champ+=champ_verif[i]+"\n";
-								//test to konw if u must show a message with error
+								//test to konw if you must show a message with error
 								statut=1;
 							}
 						}else {
@@ -169,8 +180,8 @@
 			document.form.submit();
 			}
 		}
-
 }
+
 function Dopop(link) {
 // // 	var searchstring=document.form.value[i].value;
 	var newin=window.open(link,'popup','width=600,height=400,resizable=no,toolbar=false,scrollbars=no,top');
@@ -178,7 +189,8 @@
 
 function Dopopguarantor(link) {
 
-	var newin=window.open(link,'popup','width=600,height=400,resizable=no,toolbar=false,scrollbars=no,top');
+	var newin=window.open(link,'popup','width=600,height=400,resizable=no,toolbar=false,scrollbars=yes,top');
 }
 
+
 </script>





More information about the Koha-cvs mailing list