SMF Support > SMF 2.0.x Support
Required Field for 2.0.2
(1/1)
The Wizard:
Hello:
I found the code to add a birthdate select box to my Register.template.php and now I would like to make it a required field on registration. Can anyone post the code to make it required? Below is the select box code I added.
Thanks
Wiz
--- Quote ---
global $context, $txt, $modSettings;
if (cache_get_data('intuitive_age', 120) != null)
{
$years = cache_get_data('intuitive_age', 120);
}
else
{
$years = array();
$base_year = 1904;
$current_year = date('Y');
$count = $base_year;
$age = 0;
$ages = array();
while ($count < $current_year)
{
++$count;
$years[] = $count;
}
$years = array_reverse($years);
foreach ($years as $year)
{
$ages[$year] = ++$age;
$year = array();
$year[$age] = $year;
}
cache_put_data('intuitive_age', $years, 120);
}
$days = array(
1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18,
19, 20, 21, 22, 23, 24, 25, 26,
27, 28, 29, 30, 31,
);
// Just show the pretty box!
echo '
<dl class="register_form">
<dt>
<strong>', $txt['birthdate'], ':</strong>
</dt>
<dd>
<select name="bday1" id="bday1" style="padding: 4px;">
<option value="00"', isset($context['member']['birth_date']['month']) && ($context['member']['birth_date']['month'] == '' || $context['member']['birth_date']['month'] == '00') ? ' selected="selected"' : '', '>', $txt['calendar_month'], ' </option>';
foreach ($txt['months_short'] as $key => $month)
{
echo '<option value="', $key, '"', !empty($context['member']['birth_date']['month']) && $context['member']['birth_date']['month'] == $key ? ' selected="selected"' : '', '>', $month, ' </option>';
}
echo '</select>
<select name="bday2" id="bday2" style="padding: 4px;">
<option value="00"', isset($context['member']['birth_date']['day']) && ($context['member']['birth_date']['day'] == '' || $context['member']['birth_date']['day'] == '00') ? ' selected="selected"' : '', '>', $txt['calendar_day'], ' </option>';
foreach ($days as $day)
{
echo '<option value="', $day, '"', !empty($context['member']['birth_date']['day']) && $context['member']['birth_date']['day'] == $day ? ' selected="selected"' : '', '>', $day, ' </option>';
}
echo '</select>';
if (!empty($years))
{
echo '<select name="bday3" id="bday2" style="padding: 4px;">
<option value="0000"', isset($context['member']['birth_date']['year']) && ($context['member']['birth_date']['year'] == '' || $context['member']['birth_date']['year'] == '0000') ? ' selected="selected"' : '', '>', $txt['calendar_year'], ' </option>';
foreach ($years as $key => $year)
{
echo '<option value="', $year, '"', !empty($context['member']['birth_date']['year']) && $context['member']['birth_date']['year'] == $year ? ' selected="selected"' : '', '', !empty($modSettings['coppaAge']) && $modSettings['coppaAge'] >= $year && $modSettings['coppaType'] == 0 ? ' disabled="disabled"' : '', '>', $year, ' </option>';
}
echo '</select>';
}
else
{
echo '<input type="text" name="bday3" size="4" maxlength="4" value"', $context['member']['birth_date']['year'], '" class="input_text" />';
}
echo '
</dd>
</dl>';
--- End quote ---
CapadY:
When you PM me an email address I send you a MOD which will give the possibilty to require Birthdate and/or Gender and/or Location at registration.
Navigation
[0] Message Index
Go to full version