Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet age calculation

Have Programming Question? Ask it here!
 
 
 


alagulakshmi
age calculation
1 Answer(s)      2 years and a month ago
Posted in : JSP-Servlet


pls send me the age calculation validation coding in java script. i'm waiting for ur reply...


Advertisement
View Answers

July 13, 2012 at 11:00 AM


The given javascript code calculates the age of a person. Here we have used regular expression to validate date format. If inputted date of birth is in form of dd/mm/yyyy then count age by subtracting dob into current date. you can also take specified date in place of current date to count age. getFullYear() is used here to get year of specified date.

<html>
    <head>
    <script type="text/javascript">
        function ageCount() {
            var date1 = new Date();
            var  dob= document.getElementById("dob").value;
            var date2=new Date(dob);
            var pattern = /^\d{1,2}\/\d{1,2}\/\d{4}$/; //Regex to validate date format (dd/mm/yyyy)
            if (pattern.test(dob)) {
                var y1 = date1.getFullYear(); //getting current year
                var y2 = date2.getFullYear(); //getting dob year
                var age = y1 - y2;           //calculating age 
                document.write("Age : " + age);
                return true;
            } else {
                alert("Invalid date format. Please Input in (dd/mm/yyyy) format!");
                return false;
            }

        }
    </script>
    </head>
    <body>
    Date of Birth(dd/mm/yyyy):
    <input type="text" name="dob" id="dob" />
    <input type="submit" value="Age" onclick="ageCount();">
    </body>
    </html>


Related Tutorials/Questions & Answers:
age calculation
age calculation  pls send me the age calculation validation coding in java script. i'm waiting for ur reply
Advertisements
tax calculation
tax calculation  I want you to write a program while take some amount and do the tax calculation Sr.No. Particulars Present Rate Amount in INR 1 Service Fee - 100 2 Service tax Tax 12.00% 12 Education cess
age calculator
age calculator  sir , actually m working on a project where i want the user to enter his date of birth in a jtextfield .and on doing so his age should b displayed in the next textfield automatically....plz help
Average Age of my Class?
Average Age of my Class?  average age of my class
Total Hours Calculation.
Total Hours Calculation.   Hi,How to calculate the total hours by startime and endtime.not railway time just only normal time.please help. Thanks
compare age with dob - WebSevices
compare age with dob  Thanks for your quick reply. but I need exact... as Age like(18). but we dont have specified age field for fetching. instead of age field we have dateofbirth field(YYYY-MM-DD). so how we compare age
calculation after if. user input
calculation after if. user input  System.out.print ("please select one of the following by pressing tne number on your keypad"); System.out.println(); System.out.println("1. Apples"); System.out.println("2. Oranges
Calculate an average Age of my Class?
Calculate an average Age of my Class?  average age of my class
JavaScript calculate age from date of birth
JavaScript calculate age from date of birth  How to calculate age...(); //getting dob year var age = y1 - y2; //calculating age document.write("Age : " + age); return true; } else
how to done calculation for dynamic generated textboxes in jquery/javascript/ajax?
how to done calculation for dynamic generated textboxes in jquery/javascript/ajax?  how to done calculation for dynamic generated textboxes in jquery/javascript/ajax
Calculate Age using current date and date of birth
Calculate Age using current date and date of birth In this section you will learn how to calculate the age. For this purpose, through the code, we have... to determine the age, we have used the following code
Determining the actual age from date of birth in Java
Determining the actual age from date of birth in Java... the age of a person easily through the given program. This program takes... age which determines the years, months and days of the calculated age
sql query to get name,age,phone,address from tables t1,t2,t3,t4,t5 ..
sql query to get name,age,phone,address from tables t1,t2,t3,t4,t5 ..   this is for single table : query ="SELECT name , age , pwd , phone... by name"; i want for 12 tables : i want to fetch name age pwd phone address from 12
how can you calculate you your age in daies??
how can you calculate you your age in daies??  **hi, I am beginner in java! can any one help me to write programm to calculate age in daies... * 1000); System.out.println("Your Age is: " + diffDays + " days
How automatically calculate age based on date of birth and current date using jsp and servlet?
How automatically calculate age based on date of birth and current date using jsp and servlet?  when user enters the Date of birth in one textbox then automatically age will be display on another textbox. event:Onlick Event
program to enter values from one jsp page and then do calculation on some formula and that results is displayed in another jsp
program to enter values from one jsp page and then do calculation on some formula and that results is displayed in another jsp  <%@ page language="java" import="java.util.*;"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML
Calculation Example
Calculation Example       This Example shows, how to calculate using velocity...("./src/velocity/calculation/Product.vm");   
<c: out> For Simple Calculation and Output
<c: out> For Simple Calculation and Output          One of the general purpose core library tag is <c: out>. The main function of the this tag
Java number calculation using while loop
Java number calculation using while loop In this tutorial, you will learn how to use while loop to solve certain number calculations. Here is an example that prompts the user to input two integers : FirstNum and secondNum.( FirstNum
Security in Web Service
Security in Web Service         Project Requirement Develop a web service program for Square   area calculation
Generate Error in JSP
Generate Error in JSP          In software engineering, the term refers to an incorrect action or calculation performed by software. In general we can say
MySQL Addition
MySQL Addition       MySQL Addition returns you the sum value of the total counts in a table. The Aggregate function is used to perform the calculation in SQL Query. We make use
Business Intelligence in Decision Making
. This is the age of information, technology and communication age it’s
iPhone EMI Calculator, EMI Calculator for iPhone
) and the second is Affordable Loan Calculation (ALC). The first EMI Calculation.... The second types of calculation can be done by selecting second choice of Affordable
SQL Aggregate Functions First
SQL Aggregate Functions First       SQL Aggregate Function First, that performs calculation of data. The SQL aggregate function retrieve a single value, by calculate from
Global Positioning Systems and its uses
Global Positioning Systems and its uses Global Positioning Systems are the authentic and advanced products of this age's technology. It has changed the way we communicate and keep record of the tracking procedures. Finding
History of Business Intelligence
and technology (IT) age where everything depends on the availability of information... of information age, it was very difficult to access any information in the absence
Most Influential Management Gurus of Twentieth Century
Management pundits or management gurus are considered to be the most influencing figures in leading the greatest innovations and business ideas in the economic and entrepreneurial history of the world ever since we entered the age
Java Assertion
Java Assertion Assertion are simple check  assumption  made at the beginning of the program to ensure the program is true throughout  provided by  the Java language. For example, the range of age
How GPS Tracking System Works
no longer have to resort to the age-old practices of choosing landmarks.... The technological advances of this age has brought a new facet altogether
LTO 6: Your Next Big Boost to Data Storage
dominance as the new age storage technology. In last 12 year LTO as a data
Gardens in Agra
normally called added to the beautiful monuments built of an age far gone by. Some
Kerala Travel Guide
rich culture, centuries old temples, age-old traditions and customs. From
claculation - Java Beginners
claculation  Calculation in a simple Java Program
javascript where to declare variables
;script language="javascript"> // declare variable or do your calculation... a variable in JavaScript. <Script Language="JavaScript"> var name, age; name = Java; age = 7; document.write(name); document.write("<br>"); document.write
question
question  i need a simple jsp code for monthly salary calculation
question
question  i need a simple jsp code for monthly salary calculation
write java prgram
write java prgram  write java program to offer a menu which contains 3 choices to make calculation on 3 shapes.use method for each calculation
how to calculate the employee tax - JSP-Servlet
how to calculate the employee tax  How to calculate the employee tax.Can u please send to me calculation tables
which part of the cpu does math calculations
which part of the cpu does math calculations  which part of the cpu does math calculations logical calculation
q
q  how to add 2 numbers in java   Hi, Try this: class Test{ public int add(int a,int b){ return a+b; } public static void main(String []args){ Calculation cal=new Calculation(); int
Finding A Date
Finding A Date  My Frequency Start Date is 24-08-2012 My frequency end date - not defined Calculation Frequency is Weekly(Sunday) My calculation will be from 24-08-2012 to the following sunday My question is how to find
Java stack help
Java stack help  How would I use stacks in java to do a calculation like: 4*((3+3)/(5-3
JAVA EXCEL
JAVA EXCEL  How to read the contents of an excel, perform some calculation and wrote the calculated values to another excel using poi
java
java  My program is about age calculation. It is running successfully...; ageDays = 0; } System.out.print("Age of the person : " + ageYears...."); } }   Calcuate Age import java.text.*; import java.util.
 

 

 

DMCA.com