krishna501 0 Newbie Poster
Holidays.jsp:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert Holidays Data</title>
<script src="HolidaysValidation.js" type="text/javascript"></script>
<style type="text/css">
#hihint{
position:absolute;
right:350px;
top:85px;
}
#hnhint{
position:absolute;
right:450px;
top:110px;
}
#mhint{
position:absolute;
right:450px;
top:130px;
}
#hdhint{
position:absolute;
right:330px;
top:160px;
}

</style>
</head>
<body>
<center>
<form action="" name="J" method="post" onsubmit="validateForm()">
<h1>Insert Data To Holidays Table !</h1>
<table>
	<tr>
		<td>Holiday id :</td>
		<td><input type="text" id="hid" name="holidayId"></td>
		<td></td>
		<td>
		<div id="hihint"></div>
		</td>
	</tr>

	<tr>
		<td>Holiday Name :</td>
		<td><select id="hname" name="holidayName">
			<option>Select</option>
			<option>Bhogi</option>
			<option>Sankranthi</option>
			<option>Ugadi</option>
			<option>GoodFriday</option>
			<option>IndependenceDay</option>
			<option>VinayakaChavithi</option>
			<option>Dasara</option>
			<option>VijayaDasami</option>
			<option>Diwalli</option>
			<option>Christmas</option>
			<option>Sri Rama Navami</option>
		</select></td>
		<td>
		<div id="hnhint"></div>
		</td>
	</tr>

	<tr>
		<td>Month :</td>
		<td><select id="hmonth" name="month">
			<option value="">select</option>
			<option value="0">January</option>
			<option value="1">February</option>
			<option value="2">March</option>
			<option value="3">April</option>
			<option value="4">May</option>
			<option value="5">June</option>
			<option value="6">July</option>
			<option value="7">August</option>
			<option value="8">September</option>
			<option value="9">October</option>
			<option value="10">November</option>
			<option value="11">December</option>
			</select>
		<td></td>
		<td>
		<div id="mhint"></div>
		</td>
	</tr>
	<tr>
		<td>Date :</td>
		<td><select id="cname" name="holidayMonth">
			<option value="0">select</option>
			<option value="1">January</option>
			<option value="2">February</option>
			<option value="3">March</option>
			<option value="4">April</option>
			<option value="5">May</option>
			<option value="6">June</option>
			<option value="7">July</option>
			<option value="8">August</option>
			<option value="9">September</option>
			<option value="10">October</option>
			<option value="11">November</option>
			<option value="12">December</option>
			</select>
			<select id="cname" name="holidayDate">
			<option value="0">select</option>
			<%
				for (int j = 01; j < 31; j++) {
			%>

			<option value="<%=j %>"><%=j%></option>
			<%
				}
			%>
		</select>
		 <select id="cname" name="holidayYear">
			<option value="0">select</option>
			<%
				for (int i = 2010; i <= 2020; i++) {
			%>

			<option value="<%=i %>"><%=i%></option>

			<%
				}
			%>
		</select>
			 </td>
		<td></td>
		<td>
		<div id="hdhint"></div>
		</td>
	</tr>
	<tr>
		<td></td>

		<td><br>
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit"></td>
	</tr>

</table>
</form>
</center>
</body>
</html>
HolidaysValidation.js:
var fVal = {

	getValue : function(id) {
		return document.getElementById(id).value;
	},
	showMsg : function(msg, hint_id) {
		document.getElementById(hint_id).innerHTML = msg;
	}
};

validateForm = function() {
	var id = fVal.getValue("hid");
	var name = fVal.getValue("hname");
	
	//var month = fVal.getValue("hmonth");
	//var date = fVal.getValue("hdate");
	
	//var reg=/^[0-9]{4}\-(0[1-9]|1[012])\-(0[1-9]|[12][0-9]|3[01])$/;

	if (id == "") {
		fVal.showMsg("Field should not be an empty", "hihint");
		return false;
	} else if (isNaN(id)) {
		fVal.showMsg(" ", "hihint");
		fVal.showMsg("Field should contain only numbers", "hihint");
		return false;
	}

	else if (name == "Select") {
		
		fVal.showMsg(" ", "hihint");
		fVal.showMsg("Select a Festival", "hnhint");
		return false;
		
	} 
	
	 else if ((document.J.month.selectedIndex=="")) {
		
		fVal.showMsg(" ", "hnhint");
		fVal.showMsg("Select a Month", "mhint");
		return false;
	} 

	 else if((document.J.holidayDate.selectedIndex=="") || (document.J.holidayMonth.selectedIndex=="")|| (document.J.holidayYear.selectedIndex=="")){
		
		 fVal.showMsg("", "mhint");
		 fVal.showMsg("U should select all the fields", "hdhint");
	     return false;
	 }
	 else{
		 return true;
	 }
};

hello guys the validation msg in the div adjacent to the entry parts are bliking and going and undoing the entries. i couldnt get the problem wer it lies.......can someone trace it out.....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.