Hi,
I have a javascript function that i need to translate to cfscript but am having
difficulty with finding some of the correct cf methods. the javascript code is
as follows:
function isDate(dateStr)
{
var datePat = /^(\d{1,2})(\/)(\d{1,2})(\/)(\d{4})$/;
var matchArray = dateStr.match(datePat); // is the format ok?
if (matchArray == null)
{
alert("Please enter date as dd/mm/yyyy");
return false;
}
day = matchArray[1]; // [EMAIL PROTECTED] date into variables
month = matchArray[3];
year = matchArray[5];
if (month < 1 || month > 12)
{ // check month range
alert("Date: Month must be between 1 and 12.");
return false;
}
if (day < 1 || day > 31)
{
alert("Date: Day must be between 1 and 31.");
return false;
}
if ((month==4 || month==6 || month==9 || month==11) && day==31)
{
alert("Date: Month "+month+" doesn`t have 31 days!")
return false;
}
if (month == 2)
{ // check for february 29th
var isleap = (year % 4 == 0 && (year % 100 != 0 || year
% 400 == 0));
if (day > 29 || (day==29 && !isleap))
{
alert("Date: February " + year + " doesn`t have
" + day + " days!");
return false;
}
}
return true; // date is valid
}
the main problem i am having is the with top part of the code for the pattern
matching:
var datePat = /^(\d{1,2})(\/)(\d{1,2})(\/)(\d{4})$/;
var matchArray = dateStr.match(datePat); // is the format ok?
if (matchArray == null)
{
alert("Please enter date as dd/mm/yyyy");
return false;
}
i would really appreciate any help
thanks very much
richard
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:296500
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4