
function ValidDateChars(evt)
{	
	var keycode = evt.which ? evt.which : evt.keyCode;

	if((keycode > 46 && keycode < 58) || (keycode == 45))
	{
		//event.returnValue = true;
		return true;
	}
	else
	{
		//		event.returnValue = false;
		return false;
	}	
}
	

function AllowNumbers(evt)
{
	var keycode = evt.which ? evt.which : evt.keyCode;
		
	if((keycode > 47 && keycode < 58) || keycode ==8 || keycode ==46)
	{
		//evt.returnValue= true;
		return true;
	}
	else
	{
		//evt.returnValue= false;
		return false;
	}	
}



//Allow only for upper and lower case characters.
function AllowChar(evt)
{	
	var keycode = evt.which ? evt.which : evt.keyCode;
	
	if((keycode > 64 && keycode < 91) || (keycode > 96 && keycode < 123) || keycode ==8 || keycode ==46)
	{
		//event.returnValue= true;
		return true;
	}
	else
	{
		//event.returnValue= false;
		return false;
	}	
}	
		
function isDate(dateStr) 
	{	
			
		var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
		var matchArray = dateStr.match(datePat); // is format OK?
	
		if (matchArray == null)   // Allow To Enter Null Value In Particular Field
		{
	    	alert("Please enter date as either mm/dd/yyyy or mm-dd-yyyy.");
	    	return false;
	  	} 
	
	  	// parse date into variables
		month = matchArray[1];
		day = matchArray[3];
    	year = matchArray[5];
	
		if (month < 1 || month > 12)  // check month range
		{
			alert("Month must be between 1 and 12.");
		    return false;
		}
	
	  	if (day < 1 || day > 31) 
	  	{
	    	alert("Day must be between 1 and 31.");
	    	return false;
	  	}
	
	  	if ((month==4 || month==6 || month==9 || month==11) && day==31) 
	  	{
	  		alert("Month " + month + " doesn't have 31 days!")
	    	return false;
	  	}	
	
	  	if (month == 2) // check for february 29th
		{
			var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
		    if (day > 29 || (day==29 && !isleap)) 
		   	{
	      		alert("February " + year + " doesn't have " + day + " days!");
	      		return false;
	    	}
	  	}
	  	
	  	return true;  // date is valid
	}
	
function echeck(str) {

		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID");
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID");
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID");
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID");
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID");
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID");
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID");
		    return false;
		 }

 		 return true;					
	}
