Welcome, Guest
  • Page:
  • 1

TOPIC: Date MM/DD/YYYY validation

Date MM/DD/YYYY validation 3 years 8 months ago #26351

i downloaded the script on this page

crosstec.de/support/index.php?pid=knowle...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?
  • caesss
  • caesss's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 7
  • Karma: 0
The administrator has disabled public write access.

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

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 '';
}
  • caesss
  • caesss's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 7
  • Karma: 0
The administrator has disabled public write access.

Re: Date MM/DD/YYYY validation 3 years 1 day ago #57445

I tried this script and ran into the problem of the "next" page button not working.
  • jps
  • jps's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
  • Karma: 0
The administrator has disabled public write access.
  • Page:
  • 1
Moderators: ForumSupport, lennerd, pedro81, JanZ
Time to create page: 0.128 seconds
Powered by Kunena Forum :: Joomlana_Dark-by- bz_kunena-templates

Our Discounts

Lifetime Subscription

Get lifetime access to all of our products and 2 years of professional support -- for just $149 USD. No limits on domains!. Includes all of our current and future Joomla!® extensions, WordPress® plugin, Joomla!® templates and WordPress® themes -- all of our products!

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 This email address is being protected from spambots. You need JavaScript enabled to view it. with a proof of purchase (for example a paypal receipt).
  • Await payment instructions and enjoy your membership!

Our Latest Joomla!® Templates

 
 
 

Are You Lazy? Get Pre-Made Forms!

Get pre-made forms, ready-to-run to kickstart your form projects. Our form apps section contains complete forms, such as user registrations that you can import right into your BreezingForms installation and adjust as required. read more

About

Crosstec GmbH & Co. KG

Hohenzollernring 57

50672 Cologne, Germany

Imprint


Live Chat Software