Welcome, Guest

TOPIC: Date MM/DD/YYYY validation

Date MM/DD/YYYY validation 6 years 2 weeks ago #26351


  • Posts:7 Thank you received: 1
  • caesss's Avatar
  • caesss
  • Fresh Boarder
  • Offline
  • 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 6 years 2 weeks ago #26724


  • Posts:7 Thank you received: 1
  • caesss's Avatar
  • caesss
  • Fresh Boarder
  • Offline
  • 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 5 years 4 months ago #57445


  • Posts:1
  • jps's Avatar
  • jps
  • Fresh Boarder
  • Offline
  • 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.
Moderators: ForumSupport, pedro81, tomeperica
Time to create page: 0.067 seconds

News and Updates

Get informed about new downloads, updates and more in our News and Updates newsletter.

New extension AnalyticsAnywhere released!

Track website visitors no matter if ad blockers are enabled! Check it out!

Lifetime Subscription

Special Offer! Get lifetime access to all of our current and future products and 2 years of professional support -- 149 for only 70!

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!

Pro Support Renewal Plans

If you just need professional support and no further access to downloads or simply want or need to renew professional support, you may choose between various support plans from here.