Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Wednesday, November 11, 2026
About Us
Magazine
Open Source
CVS
Services
Index  »  Projects  »  phpMyEdit  »  Forum  »  Date format valdidation

phpMyEdit General     Date format valdidation
Post new topic   Reply to topic    
 
tonymcc     Joined: 15 Jan 2009   Posts: 6  
Post Posted: 2009-01-19 18:45
Back to top  Reply with quote     

I am currently using the following code for to validate date entry is in the correct format. It works fine, however I need to allow NULL or empty strings as the date is not a required field.

Anybody got a better way or a twiddle to the regex that will do either/or?

Code:
$opts['fdd']['DatePaid'] = array(
  'name'     => 'Date Paid',
  'help'     => 'Format is YYYY-MM-DD',
  'select'   => 'T',
  'maxlen'   => 10,
  'datemask' => 'Y-m-d',
  'sort'     => true
);
$opts['fdd']['DatePaid']['js']['regexp'] ='/^\d\d\d\d-\d\d-\d\d$/';


 
tonymcc     Joined: 15 Jan 2009   Posts: 6  
Post Posted: 2009-01-21 02:44
Back to top  Reply with quote     

This is the regex change that answers the question ...

Code:
$opts['fdd']['EffDate']['js']['regexp'] = '/^\d\d\d\d-\d\d-\d\d$(?^$)/';


-Tony

tonymcc wrote:
I am currently using the following code for to validate date entry is in the correct format. It works fine, however I need to allow NULL or empty strings as the date is not a required field.

Anybody got a better way or a twiddle to the regex that will do either/or?

Code:
$opts['fdd']['DatePaid'] = array(
  'name'     => 'Date Paid',
  'help'     => 'Format is YYYY-MM-DD',
  'select'   => 'T',
  'maxlen'   => 10,
  'datemask' => 'Y-m-d',
  'sort'     => true
);
$opts['fdd']['DatePaid']['js']['regexp'] ='/^\d\d\d\d-\d\d-\d\d$/';


 
doug     Joined: 10 Feb 2003   Posts: 1013   Location: Denver, Colorado (USA)
Post Posted: 2009-01-21 14:00
Back to top  Reply with quote     

Code:
$opts['fdd']['inv_date']['js']['required'] = true;
$opts['fdd']['inv_date']['js']['regexp'] = '/^[1-2]{1}[0-9]{3}-[0-1]{1}[0-9]{1}-[0-3]{1}[0-9]{1}$/';
$opts['fdd']['inv_date']['js']['hint'] = 'An entry is required for Invoice Date YYYY-MM-DD';


Javascript Regular Expressions:
http://www.javascriptkit.com/javatutors/redev2.shtml

 
Post new topic   Reply to topic    

Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top · Feedback form · Application form
Report bug on PLATON.SK website · Terms of use · Privacy policy