Age Calculation in Java Script

Posted by Davkings under JavaScript on 7/14/2011 | Points: 10 | Views : 52649 | Status : [Member] | Replies : 8
I am ASP.Net Developer I need Age calculation in Java Script.I have two text Box once I Enter the age in the first text box in the format(DD/MM/YYYY) then it should calculate the age and give me in the next textbox.If some one give me a easy to understand code it will be helpful.Thanks in advance




Responses

Posted by: A4u_6178 on: 7/14/2011 [Member] Starter | Points: 25

Up
0
Down
TRY FOLLOWING LINK..
http://www.aleixcortadellas.com/main/2009/02/28/calculating-age-with-javascript/

Thanks & Regards,

Davkings, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jpchoudhari on: 7/14/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

http://www.google.com/search?q=calculate+age+javascript

Thanks and Regards,
Jaydeep Choudhari

Kind Regards,
Jay

Davkings, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Davkings on: 7/14/2011 [Member] Starter | Points: 25

Up
0
Down
Thank u for the replies.The code which ever you have given to me has 3 cloumns but in my case I have the ajax MaskedEditExtender for the date control so i can't take the date separately in 3 formats and cant do the calculation.So I am finding little difficulty with the code. :(

Davkings, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Susanthampy on: 7/14/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
http://javascript.internet.com/math-related/age-calculator.html

Regards,
Susan

Davkings, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jpchoudhari on: 7/14/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

refer this

http://sqlserverbuddy.blogspot.com/2011/06/hour-minute-second-between-two-date.html

you need some modifications instead of passing start date and end date send total seconds to this function and rest of the things are same.

Regards,
Jaydeep

Kind Regards,
Jay

Davkings, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Graha on: 7/15/2011 [Member] Starter | Points: 25

Up
0
Down
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<script language="javascript">
<!--
function Age()
{
var bday=parseInt(document.forms[0].txtBday.value);
var bmo=(parseInt(document.forms[0].txtBmo.value)-1);
var byr=parseInt(document.forms[0].txtByr.value);
var byr;
var age;
var now = new Date();
tday=now.getDate();
tmo=(now.getMonth());
tyr=(now.getFullYear());

{
if((tmo > bmo)||(tmo==bmo & tday>=bday))
{age=byr}

else
{age=byr+1}
alert("As of today, "+now+' \n'+", you are:"+(tyr-age)+ " years old");
}}
//-->
</script>
</head>
<body >

<form><center>
Enter your birthday&nbsp;&nbsp;<input type="text" name="txtBday" size="2"><br/>
Enter your birth Month(1-12)<input type="text" name="txtBmo"size="2"><br/>
Enter your 4 digit birth year<input type="text" name="txtByr"size="4" ><br/>
<input type="submit" value="submit" onClick="Age()"><input type="reset" value="reset"></center>
</form>
</body>
</html>


Davkings, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Graha on: 7/15/2011 [Member] Starter | Points: 25

Up
0
Down
REFER THIS

http://www.webdeveloper.com/forum/showthread.php?t=45590

Davkings, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lakn2 on: 7/15/2011 [Member] Starter | Points: 25

Up
0
Down
Refer this

http://stackoverflow.com/questions/4076321/javascript-age-calculation

Thanks&Regards
LakshmiNarayana Nalluri.

Davkings, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response