← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1674: Improve codes for checking date in jquery validation.

 

------------------------------------------------------------
revno: 1674
committer: Viet <Viet@Viet-Nguyen>
branch nick: trunk
timestamp: Fri 2010-03-19 17:10:44 +0530
message:
  Improve codes for checking date in jquery validation.
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/util/validate/jquery.validate.js


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription.
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/util/validate/jquery.validate.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/util/validate/jquery.validate.js	2010-03-19 11:25:38 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/util/validate/jquery.validate.js	2010-03-19 11:40:44 +0000
@@ -1002,8 +1002,21 @@
 	
 		// http://docs.jquery.com/Plugins/Validation/Methods/dateISO
 		dateISO: function(value, element) {
-			return this.optional(element) || /^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(value);
-			//return this.optional(element) || isDate(value, 'yyyy-MM-dd');
+			var check = false;
+			var re = /^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/
+			if( re.test(value)){
+				var adata = value.split('-');
+				var aaaa = parseInt(adata[0],10);
+				var mm = parseInt(adata[1],10);
+				var gg = parseInt(adata[2],10);
+				var xdata = new Date(aaaa,mm-1,gg);
+				if ( ( xdata.getFullYear() == aaaa ) && ( xdata.getMonth () == mm - 1 ) && ( xdata.getDate() == gg ) )
+					check = true;
+				else
+					check = false;
+			} else
+				check = false;
+			return this.optional(element) || check;
 		},