Hi There,
Created it for myself and thought i'd share it.
The aim of the following is to allow users to enter their DOB (date of birth) into 3 boxes... dd mm yyyy (UK / European Format)
i've attached an image so you can see what i mean
**Always Backup First**
Step 1:
open: includes\languages\english.php
add the following code
PHP Code:
define('TEXT_VALIDATION_DAY', 'DD');
define('TEXT_VALIDATION_MONTH', 'MM');
define('TEXT_VALIDATION_YEAR', 'YYYY');
if you need to switch to the UK Format, change the following
PHP Code:
define('DATE_FORMAT_SHORT', '%m/%d/%Y'); // this is used for strftime()
define('DATE_FORMAT_LONG', '%A %d %B, %Y'); // this is used for strftime()
define('DATE_FORMAT', 'm/d/Y'); // this is used for date()
define('DATE_TIME_FORMAT', DATE_FORMAT_SHORT . ' %H:%M:%S');
into ->
PHP Code:
define('DATE_FORMAT_SHORT', '%d/%m/%Y'); // this is used for strftime()
define('DATE_FORMAT_LONG', '%A %d %B, %Y'); // this is used for strftime()
define('DATE_FORMAT', 'd/m/Y'); // this is used for date()
define('DATE_TIME_FORMAT', DATE_FORMAT_SHORT . ' %H:%M:%S');
and
PHP Code:
////
// Return date in raw format
// $date should be in format mm/dd/yyyy
// raw date is in format YYYYMMDD, or DDMMYYYY
if (!function_exists('zen_date_raw')) {
function zen_date_raw($date, $reverse = false) {
if ($reverse) {
return substr($date, 3, 2) . substr($date, 0, 2) . substr($date, 6, 4);
} else {
return substr($date, 6, 4) . substr($date, 0, 2) . substr($date, 3, 2);
}
}
}
into->
PHP Code:
if (!function_exists('zen_date_raw')) {
function zen_date_raw($date, $reverse = false) {
if ($reverse) {
return substr($date, 0, 2) . substr($date, 3, 2) . substr($date, 6, 4);
} else {
return substr($date, 6, 4) . substr($date, 3, 2) . substr($date, 0, 2);
}
}
}
now find
PHP Code:
// text for date of birth example
define('DOB_FORMAT_STRING', 'mm/dd/yyyy');
change to: dd/mm/yyyy
and also find
PHP Code:
define('ENTRY_DATE_OF_BIRTH_ERROR', 'Is your birth date correct? Our system requires the date in this format: MM/DD/YYYY (eg 05/21/1970)');
define('ENTRY_DATE_OF_BIRTH_TEXT', '* (eg. 05/21/1970)');
Change accordingly...
save it.
Step 2:
open includes\templates\template_default\templates\tp_modules_create_account.php
find
PHP Code:
<?php
if (ACCOUNT_DOB == 'true') {
?>
<fieldset>
<legend><?php echo TABLE_HEADING_DATE_OF_BIRTH; ?></legend>
<label class="inputLabel" for="dob"><?php echo ENTRY_DATE_OF_BIRTH; ?></label>
<?php echo zen_draw_input_field('dob','', 'id="dob"') . (zen_not_null(ENTRY_DATE_OF_BIRTH_TEXT) ? '<span class="alert">' . ENTRY_DATE_OF_BIRTH_TEXT . '</span>': ''); ?>
<br class="clearBoth" />
</fieldset>
<?php
}
?>
and change it to
PHP Code:
<?php
if (ACCOUNT_DOB == 'true') {
?>
<fieldset>
<legend><?php echo TABLE_HEADING_DATE_OF_BIRTH; ?></legend>
<label class="inputLabel" for="dob"><?php echo ENTRY_DATE_OF_BIRTH; ?></label>
<input type="hidden" name="dob">
<input style="float:left;" name="day" size="2" maxlength="2" onclick="this.value=''" value="<?php echo TEXT_VALIDATION_DAY;?>"><span style="padding:5px;float:left;">/</span><input style="float:left;" name="month" size="2" maxlength="2" onclick="this.value=''" value="<?php echo TEXT_VALIDATION_MONTH; ?>"><span style="padding:5px;float:left;">/</span><input style="float:left;" name="year" size="4" maxlength="4" onclick="this.value=''" value="<?php echo TEXT_VALIDATION_YEAR; ?>">
<br class="clearBoth" />
</fieldset>
<?php
}
?>
save this...
Now we need to make sure the dates are passed into our hidden input
Step 3:
open includes\modules\pages\create_account\jscript_form_check.php
find the following
PHP Code:
function check_form(form_name) {
if (submitted == true) {
alert("<?php echo JS_ERROR_SUBMITTED; ?>");
return false;
}
error = false;
form = form_name;
error_message = "<?php echo JS_ERROR; ?>";
Add the following line under it
PHP Code:
form.dob.value = form.day.value + '/' + form.month.value + '/' + form.year.value;
save that...
Step 4:
Do the same in Step 3, but with the following file
includes\modules\pages\login\jscript_form_check.php
Thats it.... your ready to rumble
Hoped that it helped