Return to Snippet

Revision: 50427
at August 21, 2011 00:40 by tuuul


Initial Code
jQuery.validator.addMethod(
	"dateDECH",
	function(value, element) {
		var check = false;
		var re = /^\d{1,2}\.\d{1,2}\.\d{4}$/;
		if( re.test(value)){
			var adata = value.split('.');
			var dd = parseInt(adata[0],10);
			var mm = parseInt(adata[1],10);
			var yyyy = parseInt(adata[2],10);
			var xdata = new Date(yyyy,mm-1,dd);
			if ( ( xdata.getFullYear() == yyyy ) && ( xdata.getMonth () == mm - 1 ) && ( xdata.getDate() == dd ) )
				check = true;
			else
				check = false;
		} else
			check = false;
		return this.optional(element) || check;
	},
	"Please enter a correct date"
);

Initial URL

                                

Initial Description
An additional method for the jQuery validation plugin to validate a german date (dd.mm.YYYY) based on DateITA method.

Initial Title
jQuery validation additional method german date

Initial Tags
date, jquery, validation

Initial Language
jQuery