Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Streda, 25. november 2026
O nás
Magazín
Otvorený softvér
CVS
Služby
Index  »  Projekty  »  phpMyEdit  »  Fórum  »  Date format valdidation

phpMyEdit General     Date format valdidation
Odoslať novú tému   Odpovedať na tému    
 
tonymcc     Založený: 15.01.2009   Príspevky: 6  
Príspevok Zaslal: 2009-01-19 18:45
Návrat hore  Odpovedať s citátom     

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?

Kód:
$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     Založený: 15.01.2009   Príspevky: 6  
Príspevok Zaslal: 2009-01-21 02:44
Návrat hore  Odpovedať s citátom     

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

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


-Tony

tonymcc Napísal:
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?

Kód:
$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     Založený: 10.02.2003   Príspevky: 1013   Bydlisko: Denver, Colorado (USA)
Príspevok Zaslal: 2009-01-21 14:00
Návrat hore  Odpovedať s citátom     

Kód:
$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

 
Odoslať novú tému   Odpovedať na tému    

Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok · Odkazový formulár · Prihláška
Upozorniť na chybu na PLATON.SK webstránke · Podmienky použitia · Ochrana osobných údajov