Return to Snippet

Revision: 36221
at November 19, 2010 19:24 by Activetuts


Initial Code
public function checkDate(date:String):Boolean
{
	var month:String 		= "(0?[1-9]|1[012])";
	var day:String 			= "(0?[1-9]|[12][0-9]|3[01])";
	var year:String 		= "([1-9][0-9]{3})";
	var separator:String 	= "([.\/ -]{1})";

	var usDate:RegExp = new RegExp("^" + month + separator + day + "\\2" + year + "$");
	var ukDate:RegExp = new RegExp("^" + day + separator + month + "\\2" + year + "$");

	return (usDate.test(date) || ukDate.test(date) ? true:false);
}

Initial URL
http://active.tutsplus.com/tutorials/actionscript/validating-various-input-data-in-flash/

Initial Description
Today, almost everything on the web is based on user input. A contact form, a user registration form, a search box and so on. As a developer you can’t just rely on the user to write everything as it’s supposed to be. To be sure you always get the correct data from your users you will need to validate the input. (By Enabled)

Initial Title
Data Validation: checkDate Function

Initial Tags

                                

Initial Language
ActionScript 3