<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title></title>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1;" />
</head>
<body>
<form action="">
<input type="checkbox" onclick="this.form.btnSubmit.disabled = !this.checked;">
Check this in order to submit
<br /><br />
<input name="btnSubmit" type="submit" value="Submit" disabled="disabled" />
</form>
</body>
</html>
Tuesday, December 13, 2011
Enabling Disabled Submit Button by Clicking CheckBox on HTML
Friday, December 2, 2011
Calculating Age from Date of Birth in Java /JSP
<%@page import="java.text.DateFormat"%>
<%@page import="java.text.SimpleDateFormat"%>
<%
String dob = "1986-06-24"; (YYYY-MM-DD)
int yearDOB = Integer.parseInt(dob.substring(0, 4));
int monthDOB = Integer.parseInt(dob.substring(5, 7));
int dayDOB = Integer.parseInt(dob.substring(8, 10));
DateFormat dateFormat = new SimpleDateFormat("yyyy");
java.util.Date date = new java.util.Date();
int thisYear = Integer.parseInt(dateFormat.format(date));
dateFormat = new SimpleDateFormat("MM");
date = new java.util.Date();
int thisMonth = Integer.parseInt(dateFormat.format(date));
dateFormat = new SimpleDateFormat("dd");
date = new java.util.Date();
int thisDay = Integer.parseInt(dateFormat.format(date));
int age = thisYear - yearDOB;
if (thisMonth < monthDOB) {
age = age - 1;
}
if (thisMonth == monthDOB && thisDay < dayDOB) {
age = age - 1;
}
%>
<%=age%>
<%@page import="java.text.SimpleDateFormat"%>
<%
String dob = "1986-06-24"; (YYYY-MM-DD)
int yearDOB = Integer.parseInt(dob.substring(0, 4));
int monthDOB = Integer.parseInt(dob.substring(5, 7));
int dayDOB = Integer.parseInt(dob.substring(8, 10));
DateFormat dateFormat = new SimpleDateFormat("yyyy");
java.util.Date date = new java.util.Date();
int thisYear = Integer.parseInt(dateFormat.format(date));
dateFormat = new SimpleDateFormat("MM");
date = new java.util.Date();
int thisMonth = Integer.parseInt(dateFormat.format(date));
dateFormat = new SimpleDateFormat("dd");
date = new java.util.Date();
int thisDay = Integer.parseInt(dateFormat.format(date));
int age = thisYear - yearDOB;
if (thisMonth < monthDOB) {
age = age - 1;
}
if (thisMonth == monthDOB && thisDay < dayDOB) {
age = age - 1;
}
%>
<%=age%>
Subscribe to:
Posts (Atom)