Thread: DOB In Boxes

Results 1 to 1 of 1
  1. #1
    Join Date
    Dec 2008
    Posts
    35
    Plugin Contributions
    2

    Default DOB In Boxes

    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($date32) . substr($date02) . substr($date64);
          } else {
            return 
    substr($date64) . substr($date02) . substr($date32);
          }
        }
      } 
    into->
    PHP Code:
      if (!function_exists('zen_date_raw')) {
        function 
    zen_date_raw($date$reverse false) {
          if (
    $reverse) {
            return 
    substr($date02) . substr($date32) . substr($date64);
          } else {
            return 
    substr($date64) . substr($date32) . substr($date02);
          }
        }
      } 
    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
    Attached Images Attached Images  

 

 

Similar Threads

  1. DOB Validation
    By eddy_r3 in forum General Questions
    Replies: 9
    Last Post: 11 May 2012, 12:50 PM
  2. change dob
    By homebrewkits in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 2 Mar 2011, 11:38 AM
  3. Foxed by DOB
    By Kryspen in forum Templates, Stylesheets, Page Layout
    Replies: 8
    Last Post: 19 May 2010, 11:36 PM
  4. Deleting DOB
    By SpeedBird3654 in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 7 Oct 2008, 09:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg