Welcome, Guest

TOPIC: Date MM/DD/YYYY validation

Date MM/DD/YYYY validation 4 years 5 months ago #26351

  • caesss
  • caesss's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 7
  • Thank you received: 1
  • Karma: 0
i downloaded the script on this page

crosstec.org/support/index.php?pid=knowl...viewentclient&id=165

and i installed it but I noticed it didn't work. It was the same as DD/MM/YYYY. I compared it with the script for DD/MM/YYYY and it is the same (no change to the code), I think a file upload error. i tried changing the regular expression to

var pattern = /(0|1)[0-9]\x5C/[0-3][0-9]\x5C/(19|20)[0-9]{2}/\x3B\r\n

from

var pattern = /[0-3][0-9]\x5C/(0|1)[0-9]\x5C/(19|20)[0-9]{2}/\x3B\r\n

but it didn't work. What else am I missing?
The administrator has disabled public write access.

Re: Date MM/DD/YYYY validation 4 years 5 months ago #26724

  • caesss
  • caesss's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 7
  • Thank you received: 1
  • Karma: 0
I keep answering my own questions but here is the revised code in case somone else runs into the same problem.

just changed the regular expression and switch month and day

AND change the date_array (month should be 0 and day is 1)

done.


function ff_validate_date_MMDDYYYY(element, message)
{
// Regular expression used to check if date is in correct format
var pattern = /(0|1)[0-9]\/[0-3][0-9]\/(19|20)[0-9]{2}/;
if(pattern.test(element.value))
{
var date_array = element.value.split('/');
// Attention! Javascript consider months in the range 0 - 11
var month = date_array[0] - 1;
var day = date_array[1];
var year = date_array[2];

// This instruction will create a date object
source_date = new Date(year,month,day);

if(year != source_date.getFullYear())
{
return message == '' ? 'Element ' + element.name + ' failed my test' : message;
}

if(month != source_date.getMonth())
{
return message == '' ? 'Element ' + element.name + ' failed my test' : message;
}

if(day != source_date.getDate())
{
return message == '' ? 'Element ' + element.name + ' failed my test' : message;
}
}
else
{
return message == '' ? 'Element ' + element.name + ' failed my test' : message;
}

return '';
}
The administrator has disabled public write access.
The following user(s) said Thank You: iCandy_Webs

Re: Date MM/DD/YYYY validation 3 years 8 months ago #57445

  • jps
  • jps's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
  • Karma: 0
I tried this script and ran into the problem of the "next" page button not working.
The administrator has disabled public write access.
Time to create page: 0.435 seconds

Lifetime Subscription

Get lifetime access to all of our current and future products and 2 years of professional support -- for just $119 USD.

No support per domain or website installation limits! Includes all of our current and future Joomla!® extensions, WordPress® plugins, Joomla!® templates   this means, by purchasing a Lifetime Subscription you'll have it all covered!

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our 1-Year or Lifetime Subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!

Supporting the Joomla! Community

Offical Joomla! User Groups and organizers of Joomla! Days, registered at Joomla.org, are supported by Crosstec, worldwide!

If you are running a JUG or organize a Joomla! Day and you need any of our products, just write an email to info@crosstec.org and you'll get a Lifetime Membership for free!

Live Chat Software