function checkNumeric(feild,string)
{
	if(is_num(string)){
		return "\n*" + feild;
	}else
	{
		return "";
	}
}

function is_num(string)
{
	var reg = /[0-9]/;
	if(reg.test(string)){
		return true;
	}
	return false;
}
	
function check(){

var name = document.consent.pname.value;
var guardName = document.consent.gName.value;
var place = document.consent.place.value;
var activity = document.consent.act.value;
var dateFrom = document.consent.dateF.value;
var dateTo = document.consent.dateT.value;
var returnTitleString ="";
var returnString = "";
var d = new Date();
var thisYear = d.getFullYear()
var dateError ="";
var dateErrorData ="";
var numCheckString ="";
var numCheckTitle ="";

numCheckString+= checkNumeric("Name",name);
numCheckString+= checkNumeric("Parent/Guardan Name",guardName);
numCheckString+= checkNumeric("Place",place);
numCheckString+= checkNumeric("Activity",activity);

if(name == ""){
returnString+="\n* Name ";
returnTitleString = "The following Information \n needs filling out: \n";
}
if(guardName == ""){
returnString+="\n* Parent/Guardan Name";
returnTitleString = "The following Information \n needs filling out: \n";
}
if(place == ""){
returnString+="\n* Place";
returnTitleString = "The following Information \n needs filling out: \n";
}
if(activity == ""){
returnString+="\n* Activity";
returnTitleString = "The following Information \n needs filling out: \n";
}
if(dateFrom ==""){
returnString+="\n* Date From";
returnTitleString = "The following Information \n needs filling out: \n";
}

if(numCheckString !=""){
numCheckTitle = "\n\n The following fields can\'t contain numbers";
}
if(dateFrom !=""){
var dateString = dateFrom.split("/");
var day = dateString[0];
var month = dateString[1];
var year = dateString[2];
    
    if(!(day >0 && day <= 31)){
        dateErrorData+="\n - " + day + " is not a vaild Day";
        dateError = "\n\nError with Date Format";
    }
    if(!(month >0 && month <= 12)){
        dateErrorData+="\n - " + month + " is not a vaild Month";
            dateError = "\n\nError with Date Format";
    }
    if(!(year >= thisYear)){
        dateErrorData+="\n - Year "+ year +" Has Gone";
            dateError = "\n\nError with Date Format";
    }
}
if(returnString != "" || dateErrorData != "" || numCheckTitle != ""){
alert(returnTitleString + returnString +  dateError + dateErrorData + numCheckTitle + numCheckString);
return false;
}
}
