Sure fire method to validate the Date field Server Side

Regex expressions are not the perfect solution to identifying valid dates. Neither does parsing a String date using the DateFormat guarantee a correct date since the year, month and day tend to roll over. And hence Date ParseException only ensures that your date is in the correct format.
Here is a quick and sure fire method to verify that the date you entered is exactly what you intended to in the first place. (I have used a JSF backing bean snippet):

		String dateParam = ...
		DateFormat dateFormat = null;
		Date date = null;
		boolean flag = true;
		try {
			dateFormat = new SimpleDateFormat("dd/MM/yy");
			date = dateFormat.parse(dateParam);
			if (!dateFormat.format(date).equals(dateParam)) {
				msg = new FacesMessage(FacesMessage.SEVERITY_ERROR,
						"The date that you provided is invalid ", null);
				context.addMessage("dateId", msg);
				flag = false;
		} catch (ParseException e) {
			msg = new FacesMessage(FacesMessage.SEVERITY_ERROR,
					"Please enter date in dd/MM/yy format ", null);
			context.addMessage("dateId", msg);
			flag = false;
		if (flag == false) {
			return null; // redirect to original page to display error message

Javascript to toggle display text in JSF pages dynamically

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1" %>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
            <title>Insert title here</title>
            <%@ taglib uri="" prefix="h"%>
            <%@ taglib uri="" prefix="f"%>
            <%@taglib prefix="c" uri="" %>
            <script language="JavaScript">
                function toggle(id){
                ul = "ul_" + id;
                img = "img_" + id;
                ulElement = document.getElementById(ul);
                imgElement = document.getElementById(img);
                if (ulElement){
                if (ulElement.className == 'closed'){
                ulElement.className = "open";
                imgElement.src = "collapse.gif";
                ulElement.className = "closed";
                imgElement.src = "expand.gif";
                .open {
                display: block;
                .closed {
                display: none;
                li {
                list-style-type: none;
                padding-top: .2em;
                padding-bottom: .2em;
                li img {
                vertical-align: middle;
    <%int i=1; %>
            <div class="open">
                <c:forEach items="${myBackingBean.list}" var="pojoDetails"
                    <div id="item<%=i%>>">
                        <a onclick="toggle('item<%=i%>');">
                            <img src="expand.gif" alt="" id="img_item<%=i%>" border="0">
                        <c:out value="${pojoDetails.title}" />
                        <div id="ul_item<%=i%>" class="closed">
                            <div id="item<%=i%>_1">
                                <c:out value="${pojoDetails.text}" />