
//DsrEditBox is the function written for the text boxes to check if the correct values as specified are entered or not
//the parameters for the function are
// 1)input name is the name given for the textbox in the HTML Doc
// 2)reqname is the name to be displayed in the output alert messages 
//   for ex:message is"Invalid First Name!please check atlest one checkbox" then reqname is "First Name"
// 3)compulsory == compulsory if the field is compulsory in the form
// 4) type is the required type given by the user
//    for ex: if the user needs the validations for alphabets(both cases) then type = alphabet
//			  if the user needs the validations for alphanumeric then type = alphanum
//			  if the user needs the validations for alphabets and dot only then type = alpha.
//			  if the user needs the validations for alphabets,spaces and dot then type = alphasp.
//			  if the user needs the validations for alphabets,numbers,spaces and dot then type = alphanumsp.					
//			  if the user needs the validations for company Name then type = companyname
//			  if the user needs the validations for product name then type = productname
//			  if the user needs the validations for productid then type = productid
//			  if the user needs the validations for number then type = number( "+"  is notallowed here)
//			  if the user needs the validations for  positive integers then type = posinteger("+" is allowed here)					
//			  if the user needs the validations for integers(both positive and negative) then type = integer
//			  if the user needs the validations for positive Decimal numbers(user can enter "+" before number) then type = posdecimalnumber					
//			  if the user needs the validations for Decimal numbers(user can enter "+" and "-" before number) then type = negdecimalnumber
//			  if the user needs the validations for fax then type = fax					
//			  if the user needs the validations for phone then type = phone
//			  if the user needs the validations for email then type = email


function DsrEditBox(inputname,reqname,compulsory,type, decprecision, minval, maxval)
{ 
  var valid;
  var ok = true;
  valid = type;
  switch(valid)
	{
	  case "alphabet":
	  				{ 
					  	ok = true;
					  
					  	//if the user does not enter the value and the field is compulsory
					  	if ((inputname.value=="")&& (compulsory=="compulsory"))
   						 {
                            alert("\""+reqname+"\" must not be empty");
							inputname.focus();
							return false;
							break;
   						 }
						 
						 //if the user leaves spaces before entering the value
						if (inputname.value.substring(0,1)==" ") 
  						  {
    						ok = false;
    						alert ("Do not leave spaces before \""+reqname+"\"");
    						inputname.focus();
    						return false;
							break;
  						  }    
						  
						//if the user leaves spaces while entering the value  
						if (inputname.value.indexOf(" ") != -1) 
  						  {
    						ok = false;
    						alert ("Do not leave spaces while entering \""+reqname+"\"");
    						inputname.focus();
    						return false;
							break;
  						  }   
						
						//maxlength contains the length of the entered input value
						var maxlength;
                        maxlength = inputname.value.length;
                                
						//if entered input length exceeds the given length in maxval		
						if (maxlength > maxval) 
   						  {
                             	alert("\""+reqname+"\" should not exceed "+maxval+ " characters");
			          			inputname.focus();
								inputname.select();
				  				return false;
						  }
						  
						// variable temp is used to take the individual characters entered  
						//this loop is used to check if other than alphabets are entered in the field
                        for (var i=0; i<inputname.value.length; i++) 
	               		  {
		           			temp = "" + inputname.value.substring(i, i+1);
							if ((temp>="a" && temp <= "z") || (temp>="A" && temp<="Z")) 
							ok = true;
							else
				 				{
			 	  					ok = false;
			 	  					break;
  				  				}

						  }
						  
						 //if  other than alphabets are entered alert message is fired
  						if (ok == false) 
   						  {
			  				alert("Invalid \""+reqname+"\"! Only Alphabets are accepted")
		                    inputname.focus();
							inputname.select();
			  				return false;
			  				break;
	                	  }
						return true;
						break;
                 	}
					
	  //if the user enters type = "alphabets." then this case is entered				
	  case "alpha.":
	  				{ 
					  	ok = true;
					  
					    //if the user left the field empty and it is a compulsory field
					  	if ((inputname.value=="")&& (compulsory=="compulsory"))
   						 {
                            alert("\""+reqname+"\" must not be empty");
							inputname.focus();
							return false;
							break;
   						 }
						 
						 //if the user leaves spaces before entering input  
						 if (inputname.value.substring(0,1)==" ") 
  						  {
    						ok = false;
    						alert ("Do not leave spaces before \""+reqname+"\"");
    						inputname.focus();
    						return false;
							break;
  						  }
						     
			            //if the user leaves spaces while entering the value
						if (inputname.value.indexOf(" ") != -1) 
  						  {
    						ok = false;
    						alert ("Do not leave spaces while entering \""+reqname+"\"");
    						inputname.focus();
    						return false;
							break;
  						  }
						
						//maxlength contains the length of the entered input value  
						var maxlength;
                        maxlength = inputname.value.length;
                                
						if (maxlength > maxval) 
   						  {
                             	alert("\""+reqname+"\" should not exceed "+maxval+ " characters length");
			          			inputname.focus();
				  				return false;
						  }
						 
						 // variable temp is used to take the individual characters entered  
						//this loop is used to check if other than alphabets are entered in the field 
                        for (var i=0; i<inputname.value.length; i++) 
	               		  {
		           			temp = "" + inputname.value.substring(i, i+1);
							if ((temp>="a" && temp <= "z") || (temp>="A" && temp<="Z") || (temp == ".")) 
							ok = true;
							else
				 				{
			 	  					ok = false;
			 	  					break;
  				  				}

						  }
						  
  						if (ok == false) 
   						  {
			  				alert("Invalid \""+reqname+"\"! Only Alphabets and \".\" are accepted")
		                    inputname.focus();
			  				return false;
			  				break;
	                	  }
						return true;
						break;
                 	}
                        
	  case "alphasp.":
	  				{ 
					  	ok = true;
						
						//if the user does not enter the value and the field is compulsory
					    if ((inputname.value=="")&& (compulsory=="compulsory"))
   						 {
                            alert("\""+reqname+"\" must not be empty");
							inputname.focus();
							return false;
							break;
   						 }
						 
						 if (inputname.value.substring(0,1)==" ") 
  						  {
    						ok = false;
    						alert ("Do not leave spaces before \""+reqname+"\"");
    						inputname.focus();
    						return false;
							break;
  						  }   
			
						var maxlength;
                        maxlength = inputname.value.length;
                                
						if (maxlength > maxval) 
   						  {
                             	alert("\""+reqname+"\" should not exceed "+maxval+ " characters length");
			          			inputname.focus();
								inputname.select();
				  				return false;
						  }
						  
                        for (var i=0; i<inputname.value.length; i++) 
	               		  {
		           			temp = "" + inputname.value.substring(i, i+1);
							if ((temp>="a" && temp <= "z") || (temp>="A" && temp<="Z") || (temp == ".") || (temp == " ")) 
							ok = true;
							else
				 				{
			 	  					ok = false;
			 	  					break;
  				  				}

						  }
						  
  						if (ok == false) 
   						  {
			  				alert("Invalid \""+reqname+"\"! Only Alphabets, Spaces and \".\" are accepted")
		                    inputname.focus();
							inputname.select();
			  				return false;
			  				break;
	                	  }
						return true;
						break;
                 	}
 
	  case "alphasp":
	  				{ 
					  	ok = true;
						
						//if the user does not enter the value and the field is compulsory
					    if ((inputname.value=="")&& (compulsory=="compulsory"))
   						 {
                            alert("\""+reqname+"\" must not be empty");
							inputname.focus();
							return false;
							break;
   						 }
						 
						 if (inputname.value.substring(0,1)==" ") 
  						  {
    						ok = false;
    						alert ("Do not leave spaces before \""+reqname+"\"");
    						inputname.focus();
    						return false;
							break;
  						  }   
			
						var maxlength;
                        maxlength = inputname.value.length;
                                
						if (maxlength > maxval) 
   						  {
                             	alert("\""+reqname+"\" should not exceed "+maxval+ " characters length");
			          			inputname.focus();
								inputname.select();
				  				return false;
						  }
						  
                        for (var i=0; i<inputname.value.length; i++) 
	               		  {
		           			temp = "" + inputname.value.substring(i, i+1);
							if ((temp>="a" && temp <= "z") || (temp>="A" && temp<="Z") || (temp == " ")) 
							ok = true;
							else
				 				{
			 	  					ok = false;
			 	  					break;
  				  				}

						  }
						  
  						if (ok == false) 
   						  {
			  				alert("Invalid \""+reqname+"\"! Only Alphabets and Spaces are accepted")
		                    inputname.focus();
							inputname.select();
			  				return false;
			  				break;
	                	  }
						return true;
						break;
                 	}
 
 
	  case "alphanumsp.":
	  				   { 
					  	ok = true;
						
						//if the user does not enter the value and the field is compulsory
					    if ((inputname.value=="")&& (compulsory=="compulsory"))
   						 {
                            alert("\""+reqname+"\" must not be empty");
							inputname.focus();
							return false;
							break;
   						 }
						 
						 if (inputname.value.substring(0,1)==" ") 
  						  {
    						ok = false;
    						alert ("Do not leave spaces before \""+reqname+"\"");
    						inputname.focus();
    						return false;
							break;
  						  }   
			
						var maxlength;
                        maxlength = inputname.value.length;
                                
						if (maxlength > maxval) 
   						  {
                             	alert("\""+reqname+"\" should not exceed "+maxval+ " characters length");
			          			inputname.focus();
				  				return false;
						  }
						  
                        for (var i=0; i<inputname.value.length; i++) 
	               		  {
		           			temp = "" + inputname.value.substring(i, i+1);
							if ((temp>="a" && temp <= "z") || (temp>="A" && temp<="Z") || (temp>="0" && temp <= "9") || (temp == ".") || (temp == " ")) 
							ok = true;
							else
				 				{
			 	  					ok = false;
			 	  					break;
  				  				}

						  }
						  
  						if (ok == false) 
   						  {
			  				alert("Invalid \""+reqname+"\"! Only Alphabets, Numbers, Spaces and \".\" are accepted")
		                    inputname.focus();
			  				return false;
			  				break;
	                	  }
						return true;
						break;
                 	}
	  case "fax"  :				
	  case "phone":
	  				{ 
					  	ok = true;
						
						//if the user does not enter the value and the field is compulsory
					    if ((inputname.value=="")&& (compulsory=="compulsory"))
   						 {
                            alert("\""+reqname+"\" must not be empty");
							inputname.focus();
							return false;
							break;
   						 }
						 
						 if (inputname.value.substring(0,1)==" ") 
  						  {
    						ok = false;
    						alert ("Do not leave spaces before \""+reqname+"\"");
    						inputname.focus();
    						return false;
							break;
  						  } 
						  			            
						if (inputname.value.indexOf(" ") != -1) 
  						  {
    						ok = false;
    						alert ("Do not leave spaces while entering \""+reqname+"\"");
    						inputname.focus();
    						return false;
							break;
  						  }
						  
						var maxlength;
                        maxlength = inputname.value.length;
                                
						if (maxlength > maxval) 
   						  {
                             	alert("\""+reqname+"\" should not exceed "+maxval+ " characters length");
			          			inputname.focus();
				  				return false;
						  }
						  
                        for (var i=0; i<inputname.value.length; i++) 
	               		  {
		           			temp = "" + inputname.value.substring(i, i+1);
							if ((temp>="a" && temp <= "z") || (temp>="A" && temp<="Z") || (temp>="0" && temp <= "9") || (temp == "-") || (temp == "(") || (temp == ")") || (temp == "+")) 
							ok = true;
							else
				 				{
			 	  					ok = false;
			 	  					break;
  				  				}

						  }
						  
  						if (ok == false) 
   						  {
			  				alert("Invalid \""+reqname+"\"! Only Alphabets, Numeric,\"-\",\"(\",\")\", and \"+\"  are accepted")
		                    inputname.focus();
			  				return false;
			  				break;
	                	  }
						return true;
						break;
                 	}
 
	  case "email":
	  				{ 
					  	ok = true;
					    
						//if the user does not enter the value and the field is compulsory
						if ((inputname.value=="")&& (compulsory=="compulsory"))
   						 {
                            alert("\""+reqname+"\" must not be empty");
							inputname.focus();
							return false;
							break;
   						 }
						
						var tempfirst = inputname.value.substring(0,1); 
						if (tempfirst == " ") 
  						  {
    						ok = false;
    						alert ("Do not leave spaces before \""+reqname+"\"");
    						inputname.focus();
    						return false;
							break;
  						  } 
						if ((tempfirst>="0" && tempfirst <= "9") || (tempfirst == "@") || (tempfirst == ".") || (tempfirst == "_"))
  						  {
    					   		alert("Invalid \""+reqname+"\"! E-mail must not start with a \"Number\", \"_\", \"@\" and \".\"");
			          			inputname.focus();
								inputname.select();
				  				return false;
						  	} 
  						  
						 if (inputname.value.indexOf(" ")> -1)
  						  {
    					   		alert("Please do not leave spaces while entering\""+reqname+"\"");
			          			inputname.focus();
								inputname.select();
				  				return false;
						  	} 
						  
						var atsign = inputname.value.indexOf("@");
						var dotsign = inputname.value.indexOf(".");
						if ((atsign==-1) || (dotsign==-1))
						 	{
                             	alert("Invalid \""+reqname+"\"! E-mail must have only one \"@\" and atleast one \".\"");
			          			inputname.focus();
				  				return false;
						  	} 
							
						 if (atsign > 25)
						 	{
								alert("\""+reqname+"\" should not exceed 25 characters before \"@\"");
			          			inputname.focus();
								inputname.select();
				  				return false;
							}
						 if (atsign > inputname.value.lastIndexOf("."))
							{
							   	alert("\""+reqname+"\" must have at least one \".\" after \"@\"");
			          			inputname.focus();
								inputname.select();
				  				return false;
						  	 }
							 
						if ((inputname.value.substring(atsign+1,atsign+2)==".") || (inputname.value.substring(atsign+2,atsign+3)==".")) 
							{
							   	alert("Invalid \""+reqname+"\"! After \"@\" there must be atleast two characters between \"@\" and \".\" ");
			          			inputname.focus();
								inputname.select();
				  				return false;
						  	 }
						 
						var atsigncount = 0;
						 
                        for (var i=0; i<inputname.value.length; i++) 
	               		  {
		           			temp = "" + inputname.value.substring(i, i+1);
							if ((temp>="a" && temp <= "z") || (temp>="A" && temp<="Z") || (temp>="0" && temp <= "9") || (temp == "_") || (temp == "@") || (temp == ".")) 							
								{
									ok = true;
									if (temp == "@") atsigncount++;
									if (atsigncount > 1) break;
								}
							else
				 				{
			 	  					ok = false;
			 	  					break;
  				  				}

						  }
						  
						if (atsigncount > 1)
							{
								alert("Invalid \""+reqname+"\"! E-mail can have only one \"@\"")
		                    	inputname.focus();
								inputname.select();
			  					return false;
			  					break;
	                	  	}
						  
  						if (ok == false) 
   						  {
			  				alert("Invalid \""+reqname+"\"! Only alphabets, Numeric,\"_\",\"@\" and \".\"  are accepted")
		                    inputname.focus();
							inputname.select();
			  				return false;
			  				break;
	                	  }
						  
						var temp1 = "";  
						ok = true;
						for (var i=atsign; i<inputname.value.length; i++) 
	               		  {
		           			temp1 = "" + inputname.value.substring(i, i+1);
							if (temp1 == ".") 							
								{
									if  ((inputname.value.substring(i+1, i+2) == ".") || (inputname.value.substring(i+2, i+3) == "."))
										ok = false;
									if (ok == false) break;
								}
							
						  }
						
						if (ok == false) 
   						  {
			  				alert("Invalid \""+reqname+"\"! After \"@\" there must be atleast two characters between two \".\"\'s")
		                    inputname.focus();
							inputname.select();
			  				return false;
			  				break;
	                	  }  
						 
						var maxlength;
                        maxlength = inputname.value.length;
						if ((maxlength- (inputname.value.lastIndexOf(".")+1)) < 2)
						 {
                             	alert("\""+reqname+"\" must have atleast two characters after last \".\"");
			          			inputname.focus();
								inputname.select();
				  				return false;
						  }
						    
						                               
						if (maxlength > 76) 
   						  {
                             	alert("\""+reqname+"\" should not exceed 75 characters");
			          			inputname.focus();
								inputname.select();
				  				return false;
						  }
						  
						if ((maxlength)-(atsign+1) > 50)
						 {
                             	alert("\""+reqname+"\" should not exceed 50 characters after @");
			          			inputname.focus();
								inputname.select();
				  				return false;
						  }
						  
						return true;
						break;
                 	}
                        
        case "alphanum" :
                            {
                                ok = true; 
								
								//if the user does not enter the value and the field is compulsory
								if ((inputname.value=="")&& (compulsory=="compulsory"))
   									 {
                			            alert("\""+reqname+"\" must not be empty");
										inputname.focus();
										return false;
										break;
   						 			}			
						 
								if (inputname.value.substring(0,1)==" ") 
  						  			{
    									ok = false;
    									alert ("Do not leave spaces before \""+reqname+"\"");
    									inputname.focus();
    									return false;
										break;
  						  			}    
						  
								if (inputname.value.indexOf(" ") != -1) 
  						  			{
    									ok = false;
    									alert ("Do not leave spaces while entering \""+reqname+"\"");
    									inputname.focus();
    									return false;
										break;
  						  			}   
			
								var maxvalue;
								maxvalue = inputname.value.length;
			        			if (maxvalue > maxval) 
   									{
				  							alert("The Value of \""+reqname+"\" should not exceed "+maxval+ " characters ");
			          		                inputname.focus();
		              					    return false;
				  
									}
								
								for (var i=0; i<inputname.value.length; i++) 
									{
					  					temp = "" + inputname.value.substring(i, i+1);
					  					if ((temp>="0" && temp <= "9") || (temp>="a" && temp <= "z") || (temp>="A" && temp<="Z"))
		                  	    			ok = true;
					  					else
			                   				{
			                     				ok = false;
			                     				break;
  			                   				}

									}
  								if (ok == false) 
   										{
					  						alert("Invalid \""+reqname+"\"! Only Alphabets and Numeric are accepted ");
			                                inputname.focus();
		                      			    return false;
										}
								return true;
								break;
			    			}
							
	  case "companyname" :
	  						{
								 ok = true;
								var temp = "";				
								//if the user does not enter the value and the field is compulsory
								if ((inputname.value=="")&& (compulsory=="compulsory"))
   									{
                						alert("\""+reqname+"\" must not be empty");
										inputname.focus();
										return false;
									}
						 
	 							if (inputname.value.substring(0,1)==" ") 
  		  							{
										ok = false;
										alert ("Do not leave spaces before \""+reqname+"\"");
    									inputname.focus();
    									return false;
							
  		  							}   
			
							var maxlength;
    						maxlength = parseInt (inputname.value.length);
                              
							if (maxlength > maxval) 
   								{
          							alert("\""+reqname+"\" should not exceed \""+maxval+"\" characters length");
   									inputname.focus();
									inputname.select();
									return false;
	 	 						}
						  
    					for (var i=0; i<inputname.value.length; i++) 
	  						{
								temp = "" + inputname.value.substring(i, i+1);
								if ((temp>="a" && temp <= "z") || (temp>="A" && temp<="Z") || (temp>="0" && temp <= "9") || (temp == ".") || (temp == "_") || (temp == " ") || (temp == "\'") || (temp == "(") || (temp == ")") || (temp == ",") || (temp == "&") || (temp == "-")) 
								ok = true;
								else
									{
			 							ok = false;
										break;
			 						}

	  						}
		  
					if (ok == false) 
   	  					{
							alert("Invalid \""+reqname+"\"! Only Alphanumeric, Spaces, Single Quotes, Dot, Hyphen, Round Braces, \"&\" and \"_\"   are accepted");
            				inputname.focus();
							inputname.select();
							return false;
	  					}
				return true;
				}
                           
      case "productid":
	  case "productname":
	  					{
							ok = true;
							var temp = "";				
							//if the user does not enter the value and the field is compulsory
							if ((inputname.value=="")&& (compulsory=="compulsory"))
   							{
                				alert("\""+reqname+"\" must not be empty");
								inputname.focus();
								return false;
							}
						 
	 						if (inputname.value.substring(0,1)==" ") 
  		  					{
  								ok = false;
								alert ("Do not leave spaces before \""+reqname+"\"");
								inputname.focus();
    							return false;
							
  		  					}   
			
						var maxlength;
    					maxlength = inputname.value.length;
                              
					if (maxlength > maxval) 
   						{
          					alert("\""+reqname+"\" should not exceed \""+maxval+"\" characters length");
   							inputname.focus();
							inputname.select();
							return false;
	 	 				}
						  
    				for (var i=0; i<inputname.value.length; i++) 
	  					{
							temp = "" + inputname.value.substring(i, i+1);
							if ((temp>="a" && temp <= "z") || (temp>="A" && temp<="Z") || (temp>="0" && temp <= "9") || (temp == ".") || (temp == " ") || (temp == "#") || (temp == "(") || (temp == ")")  || (temp == "_")) 
								ok = true;
							else
								{
			 						ok = false;
									break;
			 					}

	  					}
		  
					if (ok == false) 
   	  					{
							alert("Invalid \""+reqname+"\"! Only Alphanumeric, Spaces, \".\", \"(\", \")\",\"#\"   are accepted")
            				inputname.focus();
							inputname.select();
							return false;
	  					}
					return true;
				}

	  
	  
	  					
	  case "number" :
                           {    
				   		 
				   				ok = true;
								
								//if the user does not enter the value and the field is compulsory
							   	if ((inputname.value=="")&& (compulsory=="compulsory"))
   								 {
            		                alert("\""+reqname+"\" must not be empty");
									inputname.focus();
									return false;
									break;
   						 		}
						 
								if (inputname.value.substring(0,1)==" ") 
  						  			{
    									ok = false;
    									alert ("Do not leave spaces before \""+reqname+"\"");
    									inputname.focus();
    									return false;
										break;
  						  			}    
						  
								if (inputname.value.indexOf(" ") != -1) 
  						  			{
    									ok = false;
    									alert ("Do not leave spaces while entering \""+reqname+"\"");
    									inputname.focus();
    									return false;
										break;
  						  			}   
								var minvalue;
				   				var maxvalue;
				   				var i;
				   
				   				for (i=0; i<inputname.value.length; i++) 
									{
					  					temp = "" + inputname.value.substring(i, i+1);
					  					if ((temp>="0" && temp <= "9"))
		                  	    			ok = true;
					  					else
			                   				{
			                     				ok = false;
			                     				break;
  			                   				}

									}
  				  				
								if (ok == false) 
   									{
					  					alert("Invalid \""+reqname+"\"! Only Whole Numbers are accepted ");
			                            inputname.focus();
		                      			return false;
					  					break;
									}
									
                             	minvalue = inputname.value;
				    			maxvalue = inputname.value;
				   				
								if ((minvalue < minval) || (maxvalue > maxval))
   									{
					  					alert("The Value of \""+reqname+"\" must be between "+minval+" and "+maxval);
			                            inputname.focus();
		                          		return false;
					  					break;
									}
                                  return true;
				  				break;
			        	} 

	  case "posinteger" :
                           {    
						        
				   		 		ok = true;
								
								//if the user does not enter the value and the field is compulsory
								if ((inputname.value=="")&& (compulsory=="compulsory"))
   								 {
            		                alert("\""+reqname+"\" must not be empty");
									inputname.focus();
									return false;
									break;
   						 		}
						 
								if (inputname.value.substring(0,1)==" ") 
  						  			{
    									ok = false;
    									alert ("Do not leave spaces before \""+reqname+"\"");
    									inputname.focus();
    									return false;
										break;
  						  			}    
						  
								if (inputname.value.indexOf(" ") != -1) 
  						  			{
    									ok = false;
    									alert ("Do not leave spaces while entering \""+reqname+"\"");
    									inputname.focus();
    									return false;
										break;
  						  			}   
								
								if (inputname.value.substring(0,1)=="-") 
  						  			{
    									ok = false;
    									alert ("Invalid \""+reqname+"\"! Only positive integers are accepted");
    									inputname.focus();
    									return false;
										break;
  						  			}   
										
								if ((inputname.value.indexOf("+") != -1) &&  (inputname.value.indexOf("+") != 0))
  						  			{
    									ok = false;
    									alert("Invalid \""+reqname+"\"! The \"+\" sign is accepted only at first position in Integers");
    									inputname.focus();
    									return false;
										break;
  				  					}
									
							if ((inputname.value.substring(0,1)=="+") && ((inputname.value.length==1)||(parseFloat(inputname.value)==0)))
  						  			{
    									ok = false;
    									alert ("Invalid \""+reqname+"\"! Please enter a number greater than \"0\" after \"+\"");
    									inputname.focus();
    									return false;
										break;
  						  			}	
								
									   
								var minvalue;
				   				var maxvalue;
								var poscount=0;
				   				var i;
				   
				   				for (i=0; i<inputname.value.length; i++) 
									{
					  					temp = "" + inputname.value.substring(i, i+1);
					  					if ((temp>="0" && temp <= "9") || (temp == "-") || (temp == "+") )
		                  	    			{			
												ok = true;
												if (temp == "+") poscount++;
											}
					  					else
			                   				{
			                     				ok = false;
			                     				break;
  			                   				}

									}
  				  				
								if (poscount > 1) 
   									{
					  					alert("Invalid \""+reqname+"\"! The \"+\" sign is accepted only at first position in Integers");
			                            inputname.focus();
		                      			return false;
					  					break;
									}
										
								if (ok == false) 
   									{
					  					alert("Invalid \""+reqname+"\"! Only Integers are accepted ");
			                            inputname.focus();
		                      			return false;
					  					break;
									}
									
                             	minvalue = parseFloat(inputname.value);
				    			maxvalue = parseFloat(inputname.value);
				   				
								if ((minvalue < parseInt(minval)) || (maxvalue > parseInt(maxval)))
   									{
					  					alert("The Value of \""+reqname+"\" must be between "+minval+" and "+maxval);
			                            inputname.focus();
		                          		return false;
					  					break;
									}
                                  return true;
				  				break;
			        	} 




	  case "integer" :
                           {    
				   		 		ok = true;
								
								//if the user does not enter the value and the field is compulsory
							   	if ((inputname.value=="")&& (compulsory=="compulsory"))
   								 {
            		                alert("\""+reqname+"\" must not be empty");
									inputname.focus();
									return false;
									break;
   						 		}
						 
								if (inputname.value.substring(0,1)==" ") 
  						  			{
    									ok = false;
    									alert ("Do not leave spaces before \""+reqname+"\"");
    									inputname.focus();
    									return false;
										break;
  						  			}    
						  
								if (inputname.value.indexOf(" ") != -1) 
  						  			{
    									ok = false;
    									alert ("Do not leave spaces while entering \""+reqname+"\"");
    									inputname.focus();
    									return false;
										break;
  						  			}   
								
								if ((inputname.value.indexOf("-") != -1) &&  (inputname.value.indexOf("-") != 0))
  						  			{
    									ok = false;
    									alert("Invalid \""+reqname+"\"! The \"-\" sign is accepted only at first position in Integers");
    									inputname.focus();
    									return false;
										break;
  						  			}
									
								if ((inputname.value.indexOf("+") != -1) &&  (inputname.value.indexOf("+") != 0))
  						  			{
    									ok = false;
    									alert("Invalid \""+reqname+"\"! The \"+\" sign is accepted only at first position in Integers");
    									inputname.focus();
    									return false;
										break;
  				  					}	
									 
                                if (((inputname.value.substring(0,1)=="+") || (inputname.value.substring(0,1)=="-")) && ((inputname.value.length==1)||(parseFloat(inputname.value)==0)))
  						  			{
    									ok = false;
    									alert ("Invalid \""+reqname+"\"! Please enter a positive or negative Integer ");
    									inputname.focus();
    									return false;
										break;
  						  			}
									
								if ((inputname.value.substring(0,1)=="-") && (inputname.value.substring(1,2)=="0"))
  						  			{
    									ok = false;
    									alert ("Invalid \""+reqname+"\"! Do not precede the Negative Number with \"0\"s");
    									inputname.focus();
    									return false;
										break;
  						  			}	
								
												  
								var minvalue;
				   				var maxvalue;
								var negcount=0;
								var poscount=0;
				   				var i;
				   
				   				for (i=0; i<inputname.value.length; i++) 
									{
					  					temp = "" + inputname.value.substring(i, i+1);
					  					if ((temp>="0" && temp <= "9") || (temp == "-") || (temp == "+") )
		                  	    			{			
												ok = true;
												if (temp == "-") negcount++;
												if (temp == "+") poscount++;
											}
					  					else
			                   				{
			                     				ok = false;
			                     				break;
  			                   				}

									}
  				  				
								if (negcount > 1) 
   									{
					  					alert("Invalid \""+reqname+"\"! The \"-\" sign is accepted only at first position in Integers");
			                            inputname.focus();
		                      			return false;
					  					break;
									}
								
								if (poscount > 1) 
   									{
					  					alert("Invalid \""+reqname+"\"! The \"+\" sign is accepted only at first position in Integers");
			                            inputname.focus();
		                      			return false;
					  					break;
									}
										
								if (ok == false) 
   									{
					  					alert("Invalid \""+reqname+"\"! Only Integers are accepted ");
			                            inputname.focus();
		                      			return false;
					  					break;
									}
									
                             	minvalue = parseFloat(inputname.value);
				    			maxvalue = parseFloat(inputname.value);
				   				
								if ((minvalue < parseFloat(minval)) || (maxvalue > parseFloat(maxval)))
   									{
					  					alert("The Value of \""+reqname+"\" must be between "+minval+" and "+maxval);
			                            inputname.focus();
		                          		return false;
					  					break;
									}
                                  return true;
				  				break;
			        	} 




		case "posdecimalnumber" :
                     {    
				   	 	ok = true;
						
						//if the user does not enter the value and the field is compulsory
				   		if ((inputname.value=="")&& (compulsory=="compulsory"))
   						 {
                            alert("\""+reqname+"\" must not be empty");
							inputname.focus();
							return false;
							break;
   						 }
						 
						if (inputname.value.substring(0,1)==" ") 
  						  {
    						ok = false;
    						alert ("Do not leave spaces before \""+reqname+"\"");
    						inputname.focus();
    						return false;
							break;
  						  }    
						  
						if (inputname.value.indexOf(" ") != -1) 
  						  {
    						ok = false;
    						alert ("Do not leave spaces while entering \""+reqname+"\"");
    						inputname.focus();
    						return false;
							break;
  						  } 
						  
						 if (inputname.value.substring(0,1)=="-") 
  						  {
    						ok = false;
    						alert ("Enter only positive Decimal Number in \""+reqname+"\"");
    						inputname.focus();
    						return false;
							break;
  						  }  
						  
						  if ((inputname.value.indexOf("+") != -1) &&  (inputname.value.indexOf("+") != 0))
  						  	{
    							ok = false;
    							alert("Invalid \""+reqname+"\"! The \"+\" sign is accepted only at first position in Decimal Numbers");
    							inputname.focus();
    							return false;
								break;
  				  			}  
						if ((inputname.value.substring(0,1)=="+") && ((inputname.value.length==1)||(parseFloat(inputname.value)==0)))
  						  {
    							ok = false;
    							alert ("Invalid \""+reqname+"\"! Please enter a Decimal number greater than \"0\" after \"+\"");
    							inputname.focus();
    							return false;
								break;
  			  			}	
								
								
						if ((inputname.value.substring(0,1)=="+") &&  (inputname.value.substring(1,2)=="."))
  						  {
    						ok = false;
    						alert ("Enter at least one Number between \""+ inputname.value.substring(0,1)+"\" and  \".\"");
    						inputname.focus();
    						return false;
							break;
  						  }  
						  
						var minvalue;
				   		var maxvalue;
				   		var i;
				   		var j=0;
						var poscount = 0;
						var dotno = 0;
				   		for (i=0; i<inputname.value.length; i++) 
							{
					  			temp = "" + inputname.value.substring(i, i+1);
					  			if ((temp>="0" && temp <= "9")||(temp==".") || (temp == "+"))
									{
		                  	          	ok = true;
						  				if (temp==".") 
											{
												j=i+1;
												dotno++;
											}
										if (temp=="+") poscount++;	
									}
					  			else
			                   		{
			                     		ok = false;
			                     		break;
  			                   		}

					 		 }
							
						if (poscount > 1) 
   						{
		  					alert("Invalid \""+reqname+"\"! The \"+\" sign is accepted only at first position in Decimal Numbers");
	                        inputname.focus();
	               			return false;
		  					break;
						}
						
						if (dotno > 1)
							{
							  	alert("Invalid \""+reqname+"\"! Only one decimal point is accepted in Decimal Numbers");
                                inputname.focus();
		                        return false;
					  			break;
				   			}
							
						

						if ((j>0) && (inputname.value.length-j) > decprecision)
				  			{	
					  			alert("Invalid \""+reqname+"\"! Only "+decprecision+" places are accepted after decimal point");
                                inputname.focus();
		                        return false;
					  			break;
				   			}
							
  				  		if (ok == false) 
   							{
					  			alert("Invalid \""+reqname+"\"! Only Decimal Numbers are accepted ");
			                  	inputname.focus();
		                        return false;
					  			break;
							}
								
                        minvalue = parseFloat(inputname.value);
				    	maxvalue = parseFloat(inputname.value);
						
				   		if ((minvalue < parseFloat(minval)) || (maxvalue > parseFloat(maxval)))
   							{
					  			alert("The Value of \""+reqname+"\" must be between "+minval+" and "+maxval);
			                  	inputname.focus();
		                        return false;
					  			break;
							}
							
                       	return true;
				  		break;
			        }         
					

			case "negdecimalnumber" :
                     {    
				   	 	ok = true;
						
						//if the user does not enter the value and the field is compulsory
						if ((inputname.value=="")&& (compulsory=="compulsory"))
   						 {
                            alert("\""+reqname+"\" must not be empty");
							inputname.focus();
							return false;
							break;
   						 }
						 
						if (inputname.value.substring(0,1)==" ") 
  						  {
    						ok = false;
    						alert ("Do not leave spaces before \""+reqname+"\"");
    						inputname.focus();
    						return false;
							break;
  						  }    
						  
						if (inputname.value.indexOf(" ") != -1) 
  						  {
    						ok = false;
    						alert ("Do not leave spaces while entering \""+reqname+"\"");
    						inputname.focus();
    						return false;
							break;
  						  }   
						  
						 if ((inputname.value.indexOf("-") != -1) &&  (inputname.value.indexOf("-") != 0))
  						  	{
    							ok = false;
    							alert("Invalid \""+reqname+"\"! The \"-\" sign is accepted only at first position in Decimal Numbers");    							inputname.focus();
    							return false;
								break;
  				  			}  
							
						if ((inputname.value.indexOf("+") != -1) &&  (inputname.value.indexOf("+") != 0))
  						  	{
    							ok = false;
    							alert("Invalid \""+reqname+"\"! The \"+\" sign is accepted only at first position in Decimal Numbers");
    							inputname.focus();
    							return false;
								break;
  				  			} 
							
						if (((inputname.value.substring(0,1)=="+") || (inputname.value.substring(0,1)=="-")) && ((inputname.value.length==1)||(parseFloat(inputname.value)==0)))
  						 	{
    							ok = false;
    							alert ("Invalid \""+reqname+"\"! Please enter a positive or negative Decimal Number ");
    							inputname.focus();
    							return false;
								break;
  				  			}
									
						if ((inputname.value.substring(0,1)=="-") && (inputname.value.substring(1,2)=="0"))
  				  			{
    							ok = false;
    							alert ("Invalid \""+reqname+"\"! Do not precede the Negative Number with \"0\"s");
    							inputname.focus();
    							return false;
								break;
  				  			}	
								 
						
						if (((inputname.value.substring(0,1)=="-") || (inputname.value.substring(0,1)=="+")) &&  (inputname.value.substring(1,2)=="."))
  						  {
    						ok = false;
    						alert ("Enter at least one Number between \""+ inputname.value.substring(0,1)+"\" and  \".\"");
    						inputname.focus();
    						return false;
							break;
  						  }
						  	
						var minvalue;
				   		var maxvalue;
						var negcount=0;
						var poscount = 0;
				   		var i;
				   		var j=0;
						var dotno = 0;
				   		for (i=0; i<inputname.value.length; i++) 
							{
					  			temp = "" + inputname.value.substring(i, i+1);
					  			if ((temp>="0" && temp <= "9")||(temp==".") || (temp=="-") || (temp=="+"))
									{
		                  	          	ok = true;
						  				if (temp==".") 
											{
												j=i+1;
												dotno++;
											}
										if (temp=="-")	negcount++;
										if (temp=="+")	poscount++;	
									}
					  			else
			                   		{
			                     		ok = false;
			                     		break;
  			                   		}

					 		 }
					if (negcount > 1) 
   						{
		  					alert("Invalid \""+reqname+"\"! The \"-\" sign is accepted only at first position in Decimal Numbers");
	                        inputname.focus();
	               			return false;
		  					break;
						}
						
					if (poscount > 1) 
   						{
		  					alert("Invalid \""+reqname+"\"! The \"+\" sign is accepted only at first position in Decimal Numbers");
	                        inputname.focus();
	               			return false;
		  					break;
						}
				   		
					if (dotno > 1)
							{
							  	alert("Invalid \""+reqname+"\"! Only one decimal point is accepted in Decimal Numbers");
                                inputname.focus();
		                        return false;
					  			break;
				   			}

						if ((j>0) && (inputname.value.length-j) > decprecision)
				  			{	
					  			alert("Invalid \""+reqname+"\"! Only "+decprecision+" places are accepted after decimal point");
                                inputname.focus();
		                        return false;
					  			break;
				   			}
							
  				  		if (ok == false) 
   							{
					  			alert("Invalid \""+reqname+"\"! Only Decimal Numbers are accepted ");
			                  	inputname.focus();
		                        return false;
					  			break;
							}
				
                       	minvalue = parseFloat(inputname.value);
		    			maxvalue = parseFloat(inputname.value);
						
				   		if ((minvalue < parseFloat(minval)) || (maxvalue > parseFloat(maxval)))
   							{
					  			alert("The Value of \""+reqname+"\" must be between "+minval+" and "+maxval);
			                    inputname.focus();
		                        return false;
					  			break;
							}
							
                       return true;
				  		break;
			        }         
	
				}
	return true;
  
	}


//DsrCheckBox function is used to check if atlest one of the checkbox group is checked or not
//inputname is the checkbox group name
//reqname is the name to be displayed in the output alert messages 
//for ex:message is"Invalid Checking!please check atlest one checkbox" then reqname is "checking"
//compulsory field is given if atlest one of the checkbox group is to be checked
//if compulsory field is given the value "compulsory" then at least one of the boxes must be checked
//the checkall field is given the value of "all" if by pressing this all the check boxes must
//the checkall field is given the value of "deselectall" if by pressing this all the check boxes must
//are deselected
	
function DsrCheckBox(inputname,reqname,compulsory,checkall)
{
	//if checkall is "all" then all the checkboxes will be checked
	// For any other value  all the boxes will not be checked
	if (checkall == "all")
		{    
			for (i = 0; i < inputname.length; i++)
			inputname[i].checked = true ;
		}
	if (checkall == "deselectall")
		{    
			for (i = 0; i < inputname.length; i++)
			inputname[i].checked = false ;
		}	
	
	//if compulsory == "compulsory" then only it will check if atleast one value is checked or not 	
	if (compulsory == "compulsory")
	{	
		var checkSelected = false;
		
		//for all the checkbox group it is checked whether atleast one value is checked or not
		for (i = 0;  i < inputname.length;  i++)
			{
				if (inputname[i].checked)
					{
						checkSelected = true;
						break;
					}
			}
		//if atlest one of the checkbox group is not checked then the message is fired	
		if (!checkSelected)
			{
				alert("Please select at least one of the \"" + reqname + "\" options");
				return (false);
			}
	}
	return true;
}		

//DsrRadioButton function is used to check atleast one of the radio button group is selected or not
//inputname is the checkbox group name
//reqname is the name to be displayed in the output alert messages 
//for ex:message is"Invalid Radio!please check atlest one checkbox" then reqname is "Radio"
//compulsory field is given if atlest one of the Radiobutton group is to be selected

function DsrRadioButton(inputname,reqname,compulsory)
	{
		//if compulsory == "compulsory" then only atlest one of the radio button group must be selected
		if (compulsory == "compulsory")
		 	{
				var radioSelected = false;
				//for all the RAdio Button group it is checked whether atleast one value is selected or not
				for (i = 0;  i < inputname.length;  i++)
					{
						if (inputname[i].checked)
						{
							radioSelected = true;
							break;
						}
					}
				//if not selected then the message is fired
				if (!radioSelected)
					{
						alert("Please select one of the \""+ reqname+ "\" options.");
						return (false);
					}
			}
			return true;
	}


//DsrTextArea is used to check if the text area is filled or not
//inputname is the Textarea field name given in HTML doc
//reqname is the name to be displayed in the output alert messages 
//for ex:message is"Invalid Essay!please check atlest one checkbox" then reqname is "Essay"
//compulsory field is given if field is compulsory
//if compulsory field is given the value "compulsory" if the field is compulsory
//the maxlength field is the number of characters that can be entered in the text area 
	
function DsrTextArea(inputname,reqname,compulsory,maxlength)
	{

		//if the field is compulsory and user do not enter the value then the message is fired
		if ((inputname.value=="")&& (compulsory=="compulsory"))
   			{
                alert("\""+reqname+"\" must not be empty");
				inputname.focus();
				return false;
			}
		//if the field is compulsory only then the checking is done	
		if (compulsory == "compulsory")
		{
		
			//if the number of characters enterd increases the maxlength given then message is fired
			if (inputname.value.length > maxlength)
				{
					alert("You have exceeded the maximum length of \"" + maxlength + "\" characters in the \""+reqname+"\"");
					inputname.focus();
					return (false);
				}
		}
		return true;
	}

//DsrPassword is used to check if the password field is filled or not and exceeded the given length or not
// inputname is the password field name given in HTML doc
//if compulsory == "compulsory" then only the field is validated
//maxlength gives the maximum length of the password that can be entered


function DsrPassword(inputname,compulsory,maxlength)
 	{

	// if compulsory == "compulsory and the user does not enter any value then message is fired
		if ((inputname.value=="")&& (compulsory=="compulsory"))
   			{
                alert("\"Password\" must not be empty");
				inputname.focus();
				return false;
			}
			
			
		if (compulsory == "compulsory")
			{
			
				//if the user enters more charactes than the maxlength then the message is fired
				if (inputname.value.length > maxlength)
					{
						alert("\"Password\" should not exceed \""+ maxlength + "\" characters") ;
						inputname.focus();
						inputname.select();
						return (false);
					}
				}
			return true;
		}

//DsrDropdownBox function is used to check if atlest one of the dropdowns are selected are not
//inputname is the name given for the drop down list in the html Doc.
//reqname is the name to be displayed in the output alert messages 
//for ex:message is"Invalid year!please select atleast one year" then reqname is "year"
//if (compulsory== "compulsory) then the field must be selected

function DsrDropdownBox(inputname,reqname,compulsory)
	{

		//if (compulsory == "compulsory") and the user does not select atlest one of the drop
		//down list the the message is fired
	 	if ((compulsory == "compulsory") && (inputname.selectedIndex <= 0))
			{
				alert("Please select one of the \""+reqname+"\" options.");
				inputname.focus();
				return (false);
			}
		return true;
	}


//DsrMultiSelect function is used to check if atlest one of the MultiSelect are selected are not
//inputname is the name given for the MultiSelect  list in the html Doc.
//reqname is the name to be displayed in the output alert messages 
//for ex:message is"Invalid user name!please select atleast one user name" then reqname is "user name"
//if (compulsory== "compulsory) then the field must be selected

function DsrMultiSelect(inputname,reqname,compulsory)
	{	
		//if (compulsory == "compulsory") then atleast one of the multi select boxes must be selected
	 	if (compulsory == "compulsory") 
			{
				var numSelected = 0;
				var i;
				for (i = 0;  i < inputname.length;  i++)
					{
						if (inputname.options[i].selected)
						numSelected++;
					}

				if (numSelected == 0)
				{
					alert("Please select at least one of the \""+reqname+"\" options");
					inputname.focus();
					return (false);
				}
			}
		return true;
	}
	
function leapyear(year)
	{
		if (((year%4) == 0)	&& ((year%100) != 0) )
			return true;
		else
			{
				if  (((year%100) == 0) && ((year%400) == 0))
					return true;
				else return false;
			}
	}	

//DsrDateText is used to check whether the user enterd in the specified format for the date 
//i.e., dd/mm/yyyy
//input name is the name given for the text box for yesr in the Html doc
//if Compulsory==compulsory then it indicates the field is to be compulsory in form 

			    
function DsrDateText(inputname, compulsory)
	{
		var ok = true;
		
		//if the user does not enter the value in the year text box the mesage is fired 
		if ((inputname.value=="")&& (compulsory=="compulsory"))
   			{
            	alert("\"Date\" field must not be empty");
				inputname.focus();
				return false;
			}
		
		//if the user exceeds the specified format length then the message is fired
		if (inputname.value.length > 10) 
			{
				ok = false;	
				alert("Invalid \"Date\"! Only \"DD/MM/YYYY\" format is accepted ");
			    inputname.focus();
		        return false;
			}
			
		//slash is the var which counts the number of slashes given by the user	
		var slash = 0;		
		for (var i=0; i<inputname.value.length; i++) 
			{
				temp = "" + inputname.value.substring(i, i+1);
				 if ((temp>="0" && temp <= "9") || (temp == "/"))
					{				 
		     	    	ok = true;
						if (temp == "/") slash++;
					}
				 else
			    	{
			        	ok = false;
			            break;
					}

			}
			
		if (ok == false)
			{
			   alert("Invalid \"Date\"! Only numbers and \"/\" are accepted in date field ");
			   inputname.focus();
		       return false;
			 }
		if (slash < 2)
		 	{
			   alert("Invalid \"Date\"! Date Format must have at least two \"/\"s ");
			   inputname.focus();
		       return false;
			 }
		
		if (slash > 2)
		 	{
			   alert("Invalid \"Date\"! Date Format can have only two \"/\"s ");
			   inputname.focus();
		       return false;
			 }
		
		//if the user does not enter any value  before first slash						 
		if (inputname.value.indexOf("/")==0)
			{
				alert(" Please enter the \"Day\" before first \"/\"");
			    inputname.focus();
		        return false;
			} 
			
		//if the user does not enter any value after first slash	
		if ((inputname.value.lastIndexOf("/")-inputname.value.indexOf("/"))==1)
			{
				alert(" Please enter the \"Month\" after first \"/\"");
			    inputname.focus();
		        return false;
			} 
			
		//if the user does not give year above 1000 and below 2050	
		if ((inputname.value.length - (inputname.value.lastIndexOf("/")+1)) != 4)
			{
				alert("Invalid \"Year\"! Please enter \"Year\" between 1000 A.D and 2050 A.D");
			    inputname.focus();
		        return false;
			}
		 
		if (slash == 2)
			{	
				//var fstslash cathes the position of the first slash
				var fstslash = inputname.value.indexOf("/");
				//var lstslash cathes the position of the last slash
				var lstslash = inputname.value.lastIndexOf("/");
				var temp1 = "";
				for (var i =lstslash+1;i<inputname.value.length; i++)
			  	temp1 = temp1 + inputname.value.substring(i, i+1);
				
				//wyear,wday,wmonth consits of the corresponding values eneterd by the user
				var wyear = parseInt(temp1);
			
				if  (fstslash == 1)
					{
						var wday = parseInt(inputname.value.substring(0,1));
					}
				else if (fstslash == 2)
					{
						var wday = parseInt(inputname.value.substring(0,2));
					} 
					
				if (lstslash == 5)
				   	{
						var wmonth = parseInt(inputname.value.substring(3,5));
					}
				else if ((lstslash == 4) && (fstslash == 1))
					{
						var wmonth = parseInt(inputname.value.substring(2,4));
					}
				else if ((lstslash == 4) && (fstslash == 2))
					{
						var wmonth = parseInt(inputname.value.substring(3,4));
					}
				else if (lstslash == 3)
					{
						var wmonth = parseInt(inputname.value.substring(2,3));
					}
			
			//if month enterd is greater than 12		
			if ((wmonth > 12) || (wmonth <= 0 ))
				{
					alert("Please enter a Month between \"1\" and \"12\"");
					inputname.focus();
					return (false);
				}
			
			//if the month entered consists of 30 days and user enters more
			if (((wmonth == 4) || (wmonth == 6) || (wmonth == 9) || (wmonth == 11)) && (wday > 30))
			{
				alert("There are only 30 days in month \"" + wmonth+"\"");
				inputname.focus();
				return (false);
			}
			
			//if the month entered consists of 31 days and user enters more			
			if (((wmonth == 1) || (wmonth == 3) || (wmonth == 5) || (wmonth == 7) || (wmonth == 8) || (wmonth == 10) || (wmonth == 12)) && (wday>31))
			{
				alert("There are only 31 days in month \"" + wmonth+"\"");
				inputname.focus();
				return (false);
			}
			
			//if the month is feb it contains 29 days in leap year and 28 days in normal year
			if (wmonth == 2) 
			{
				var ok = false;
		    
		 		if (((wyear%4) == 0)	&& ((wyear%100) != 0))
					 ok = true;
				else
					{
						if  (((wyear%100) == 0) && ((wyear%400) == 0))
						ok = true;
						else ok = false;
					}
				if ((ok == false) && (wday > 28))
						{
							alert("There are only 28 days in month \"2\" of " +wyear+ " A.D");
							inputname.focus();
							return (false);
						}
				if  ((ok == true) && (wday > 29))
						{
							alert("There are only 29 days in month \"2\" of " + wyear+ "A.D");
							inputname.focus();
							return (false);
						}
				}
		
		//if enetred year is greater than 2050 and below 1000
		if ((wyear < 1000) || (wyear > 2050))
			{
				alert("Invalid \"Year\"! Please enter \"Year\" between 1000 A.D and 2050 A.D");
			    inputname.focus();
		        return false;
			}				
			}
		else
			{
			   alert("Invalid \"Date\"! Only \"DD/MM/YYYY\" format is accepted ");
			   inputname.value="";
		       inputname.focus();
		       return false;
			 }
			
			return true;
}	


//DsrDateDropDown is used to check whether the user selected the day month and year from the
// three drop down boxes for the corresponding
//day is the name of the drop down box given for day in HTML DOC
//month is the name of the drop down box given for month in HTML DOC
//year is the name of the drop down box given for year in HTML DOC
//if Compulsory==compulsory then it indicates the field is to be compulsory in form 


function DsrDateDropDown(day,month,year,compulsory)
	{
		//if the day is not selected from corresponding drop down box
		if ((day.selectedIndex <= 0) && (compulsory == "compulsory"))
			{
				alert("Please select a \"Day\"");
				day.focus();
				return (false);
			}
			
			
		//if the month is not selected from corresponding drop down box
		if ((month.selectedIndex <= 0) && (compulsory == "compulsory"))
			{
				alert("Please select a \"Month\"");
				month.focus();
				return (false);
			}

		//if the year is not selected from corresponding drop down box
		if ((year.selectedIndex <= 0) && (compulsory == "compulsory"))
			{
				alert("Please select a \"Year\"");
				year.focus();
				return (false);
			}
		
		//if the month is feb it contains 29 days in leap year and 28 days in normal year 
	
		if (month.selectedIndex == 2) 
			{
				var yrselected = parseInt(year.options[year.selectedIndex].value);
		   		var ok = false;
		    
		 		if (((yrselected%4) == 0)	&& ((yrselected%100) != 0))
					 ok = true;
				else
					{
						if  (((yrselected%100) == 0) && ((yrselected%400) == 0))
						ok = true;
						else ok = false;
					}
				if ((ok == false) && ((day.selectedIndex == 31) || (day.selectedIndex == 30) || (day.selectedIndex == 29)))
						{
							alert("There are only 28 days in \"February\" of " + year.options[year.selectedIndex].value+ "A.D");
							day.focus();
							return (false);
						}
				if  ((ok == true) && ((day.selectedIndex == 31) || (day.selectedIndex == 30)))
						{
							alert("There are only 29 days in \"February\" of " + year.options[year.selectedIndex].value+ "A.D");
							day.focus();
							return (false);
						}
				}
				
		//if the month entered consists of 30 days and user selects 31		
		if (((month.selectedIndex == 4) || (month.selectedIndex == 6) || (month.selectedIndex == 9) || (month.selectedIndex == 11)) && (day.selectedIndex == 31))
			{
				alert("There are only 30 days in \"" + month.options[month.selectedIndex].value+"\"");
				day.focus();
				return (false);
			}
		
	return true;
	}

//DsrDateDropDownYearText is used to check whether the user selected the day, month and 
//entered the correct year from the two drop down boxes and text box for the corresponding
//day is the name of the drop down box given for day in HTML DOC
//month is the name of the drop down box given for month in HTML DOC
//year is the name of the Text box given for year in HTML DOC
//if Compulsory==compulsory then it indicates the field is to be compulsory in form 

		
function DsrDateDropDownYearText(day,month,year,compulsory)
	{
		
		//if the day is not selected from corresponding drop down box
		if ((day.selectedIndex <= 0) && (compulsory == "compulsory"))
			{
				alert("Please select a \"Day\"");
				day.focus();
				return (false);
			}
		
		//if the month is not selected from corresponding drop down box
		if ((month.selectedIndex <= 0) && (compulsory == "compulsory"))
			{
				alert("Please select a \"Month\"");
				month.focus();
				return (false);
			}

		//if the year is not enetered in the text box
		if ((year.value=="") && (compulsory == "compulsory"))
			{
				alert("Please enter the \"Year\"");
				year.focus();
				return (false);
			}
		var  ok = true;
		var i;
		for (i=0; i<year.value.length; i++) 
			{
					  temp = "" + year.value.substring(i, i+1);
					  if ((temp>="0" && temp <= "9"))
		                  	    ok = true;
					  else
			                   {
			                     ok = false;
			                     break;
  			                   }

			}
		
		//if the user enters other than numbers	
  	    if (ok == false) 
   			{
		      	alert("Invalid \"Year\"! Only numbers can be entered ");
			    year.value="";
		        year.focus();
		        return false;
			}
        
		//if the entered year is not between 1000 and 2050
		if ((parseInt(year.value) < 1000) || (parseInt(year.value) > 2050))
   				{
					  alert("Invalid \"Year\"! Please enter \"Year\" between 1000 A.D and 2050 A.D");
	                  year.focus();
		              return false;
					  
					}
                      
		//if the month is feb it contains 29 days in leap year and 28 days in normal year					
		if (month.selectedIndex == 2) 
			{
				var yrselected = parseInt(year.value);
		   		var ok = false;
		    
		 		if (((yrselected%4) == 0)	&& ((yrselected%100) != 0))
					 ok = true;
				else
					{
						if  (((yrselected%100) == 0) && ((yrselected%400) == 0))
						ok = true;
						else ok = false;
					}
				if ((ok == false) && ((day.selectedIndex == 31) || (day.selectedIndex == 30) || (day.selectedIndex == 29)))
						{
							alert("There are only 28 days in \"February\" of " + yrselected+" A.D" );
							day.focus();
							return (false);
						}
				if  ((ok == true) && ((day.selectedIndex == 31) || (day.selectedIndex == 30)))
						{
							alert("There are only 29 days in \"February\" of" + yrselected+" A.D");
							day.focus();
							return (false);
						}
				}
				
		//if the month entered consists of 30 days and user selects 31		
		if (((month.selectedIndex == 4) || (month.selectedIndex == 6) || (month.selectedIndex == 9) || (month.selectedIndex == 11)) && (day.selectedIndex == 31))
			{
				alert("There are only 30 days in \"" + month.options[month.selectedIndex].value+"\"");
				day.focus();
				return (false);
			}
		
		   
		   
		
	return true;
	}




