Lines 145-150
Link Here
|
145 |
return 0; |
145 |
return 0; |
146 |
} |
146 |
} |
147 |
|
147 |
|
|
|
148 |
function CalculateAge(dateofbirth) { |
149 |
var today = new Date(); |
150 |
var dob = new Date($("#dateofbirth").datepicker( 'getDate' )); |
151 |
|
152 |
var nowyear = today.getFullYear(); |
153 |
var nowmonth = today.getMonth(); |
154 |
var nowday = today.getDate(); |
155 |
|
156 |
var birthyear = dob.getFullYear(); |
157 |
var birthmonth = dob.getMonth(); |
158 |
var birthday = dob.getDate(); |
159 |
|
160 |
var year = nowyear - birthyear; |
161 |
var month = nowmonth - birthmonth; |
162 |
var day = nowday - birthday; |
163 |
|
164 |
if(day < 0) { |
165 |
month = parseInt(month) -1; |
166 |
} |
167 |
|
168 |
if(month < 0) { |
169 |
year = parseInt(year) -1; |
170 |
month = 12 + month; |
171 |
} |
172 |
|
173 |
var age_string = "Age: "; |
174 |
if (year) { age_string += year + " year(s) "; } |
175 |
if (month) { age_string += month + " month(s) "; } |
176 |
|
177 |
var elem = $("#dateofbirth").siblings(".hint").first().html(age_string); |
178 |
} |
148 |
|
179 |
|
149 |
|
180 |
|
150 |
var MSG_SEPARATOR = _("Separator must be / in field %s"); |
181 |
var MSG_SEPARATOR = _("Separator must be / in field %s"); |
Lines 344-352
Link Here
|
344 |
Date of birth: </label> |
375 |
Date of birth: </label> |
345 |
|
376 |
|
346 |
[% IF ( dateformat == "metric" ) %] |
377 |
[% IF ( dateformat == "metric" ) %] |
347 |
<input type="text" id="dateofbirth" name="dateofbirth" size="20" onchange="CheckDate(document.form.dateofbirth);" value="[% UNLESS opduplicate %][% dateofbirth %][% END %]" /> |
378 |
<input type="text" id="dateofbirth" name="dateofbirth" size="20" onchange="CheckDate(document.form.dateofbirth); CalculateAge(document.form.dateofbirth);" value="[% UNLESS opduplicate %][% dateofbirth %][% END %]" /> |
348 |
[% ELSE %] |
379 |
[% ELSE %] |
349 |
<input type="text" id="dateofbirth" name="dateofbirth" size="20" value="[% UNLESS opduplicate %][% dateofbirth %][% END %]" /> |
380 |
<input type="text" id="dateofbirth" name="dateofbirth" size="20" onchange="CalculateAge(document.form.dateofbirth);" value="[% UNLESS opduplicate %][% dateofbirth %][% END %]" /> |
350 |
[% END %] |
381 |
[% END %] |
351 |
|
382 |
|
352 |
[% IF ( mandatorydateofbirth ) %]<span class="required">Required</span>[% END %] |
383 |
[% IF ( mandatorydateofbirth ) %]<span class="required">Required</span>[% END %] |
353 |
- |
|
|