| Index
» Projekty
» phpMyEdit
» Fórum
» Date format valdidation |
 |
tonymcc
Založený: 15.01.2009
Príspevky: 6
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
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)
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
|
|
|
|