function IsNumeric(sText)

{

var ValidChars = "0123456789-.";

var IsNumber=true;

var Char;

for (i = 0; i < sText.length && IsNumber == true; i++)

{

Char = sText.charAt(i);

if (ValidChars.indexOf(Char) == -1)

{

IsNumber = false;

}

}

return IsNumber;

}

function checkphoneno(frmsubmit)

{
alert("sdfgsd");
if (!IsNumeric(frmsubmit.mobile.value))

{

alert('Please provide a valid Telephone No. containing integers only')

frmsubmit.mobile.focus();

frmsubmit.mobile.value=""

return false;

}



}
function validateNumber(field, msg, min, max)
{
if (!min) { min = 10 }
if (!max) { max = 10 }

if ( (parseInt(field.value) != field.value) ||
field.value.length < min || field.value.length > max) {
msg="Only 10 digit mobile number will be acceptable.";
alert(msg);

field.focus();

field.value=""

return false;

}

return true;
}
function submitform(condition)
{
	var condition=condition;
	//alert(condition);
	if(condition=="document.frmsubmit2"){
var len=document.frmsubmit.elements['course[]'].length;
flag=0;
for(i=0;i<len;i++)
{
   if(document.frmsubmit.elements['course[]'][i].type=="checkbox")
   {
	if(document.frmsubmit.elements['course[]'][i].checked==true)
	 { 
	   flag=1;
	   break;
	 }
   }
}//end of for
	}
if((document.frmsubmit.name.value=="")||(document.frmsubmit.name.value=="Name"))
{
alert("Kindly fill in your Name!");
document.frmsubmit.name.focus();
return false;
}
else if(containsdigit(document.frmsubmit.name.value)==true)
{
alert("Name should not contain numbers!");
document.frmsubmit.name.focus();
return false;
}
else if(specialchar(document.frmsubmit.name.value)==true)
{
alert("Name should not contain special characters!")
document.frmsubmit.name.focus();
return false;
}
else if(document.frmsubmit.centername.value==0)
{
alert("Kindly select the Nearest Frankfinn Centre");
document.frmsubmit.centername.focus();
return false;
}
else if(document.frmsubmit.dobdd.value==0)
{
alert("Kindly select Day!");
document.frmsubmit.dobdd.focus();
return false;
}
else if(document.frmsubmit.dobmm.value==0)
{
alert("Kindly select Month!");
document.frmsubmit.dobmm.focus();
return false;
}
else if(document.frmsubmit.dobyyyy.value==0)
{
alert("Kindly select Year!");
document.frmsubmit.dobyyyy.focus();
return false;
}


else if(document.frmsubmit.email.value=='')
{
alert("Kindly fill in your Email Id!");
document.frmsubmit.email.focus();
return false;
}
else if( (document.frmsubmit.email.value!='') && (validateemailv2(document.frmsubmit.email.value)==false) )
{
alert("Kindly fill in a valid Email Id!");
document.frmsubmit.email.focus();
return false;
}


else if(((document.frmsubmit.phone.value=='')||(document.frmsubmit.phone.value=="Telephone No.")) &&((document.frmsubmit.mobile.value=='')||(document.frmsubmit.mobile.value=='Mobile No.')))
{
alert("Kindly fill either Landline or Mobile Number!");
return false;
}
else if((document.frmsubmit.mobile.value=='')&&(containsalph(document.frmsubmit.phone.value)==true))
{
alert("Kindly fill Numeric values for Landline");
return false;
}
else if(((document.frmsubmit.mobile.value=='')||(containsalph(document.frmsubmit.mobile.value)==true)||(foundstdcode(document.frmsubmit.mobile.value)==false)||(document.frmsubmit.mobile.value.length<10))&&((document.frmsubmit.phone.value=='')||(document.frmsubmit.phone.value=="Telephone No.")))
{
alert("Kindly fill in 10 digit Mobile number Starting!");
return false;
}

else if(document.frmsubmit.education.value=='nil')
{
alert("Kindly select your Qualification");
document.frmsubmit.education.focus();
return false;
}
else if(flag==0)
{
	alert("Kindly select Course");
	return false;
}
else if(document.frmsubmit.city.value=='nil')
{
alert("Kindly select the City name");
document.frmsubmit.city.focus();
return false;
}
else if(document.frmsubmit.city.value=='nil')
{
alert("Kindly select the City name");
document.frmsubmit.city.focus();
return false;
}

//else if(document.getElementById('verifymob').value!= "1"){
// alert("Kindly put a valid mobile no. and verify it");
// document.frmsubmit.mobile.focus(); 
// return false;  
//}

else {
document.frmsubmit.submit();
}
}
function foundstdcode(param)
{temp = new String(param);phone = temp.substr(0,1);
/*if(phone==9) // || phone==9)
{return true;}
else{return false;
}*/
}
function containsdigit(param)
{
mystrLen = param.length;
for(i=0;i<mystrLen;i++)
{
if((param.charAt(i)=="0") || (param.charAt(i)=="1") || (param.charAt(i)=="2") || (param.charAt(i)=="3") || (param.charAt(i)=="4") || (param.charAt(i)=="5") || (param.charAt(i)=="6") || (param.charAt(i)=="7") || (param.charAt(i)=="8") || (param.charAt(i)=="9"))
{
return true;
}
}
return false;
}
function specialchar(param)
{
mystrLen = param.length;
for(i=0;i<mystrLen;i++)
{
if((param.charAt(i)==".") || (param.charAt(i)=="'")||(param.charAt(i)=="/")||(param.charAt(i)=="*")||(param.charAt(i)=="#")||(param.charAt(i)=="$")||(param.charAt(i)=="%")||(param.charAt(i)=="@")||(param.charAt(i)=="!"))
{return true;}
}return false;}

function validateemailv2(email)
{
// a very simple email validation checking.
// you can add more complex email checking if it helps
var splitted = email.match("^(.+)@(.+)$");
if(splitted == null) return false;
if(splitted[1] != null )
{
var regexp_user=/^\"?[\w-_\.]*\"?$/;
if(splitted[1].match(regexp_user) == null) return false;
}
if(splitted[2] != null)
{
var regexp_domain=/^[\w-\.]*\.[a-za-z]{2,4}$/;
if(splitted[2].match(regexp_domain) == null)
{
var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
if(splitted[2].match(regexp_ip) == null) return false;
}
return true;
}
return false;
}
function containsalph(param)
{
mystrLen = param.length;
for(i=0;i<mystrLen;i++)
{
if((param.charAt(i)<"0")||(param.charAt(i)>"9"))
{
return true;
}
}
return false;
}
function Trim(strValue) {
var j=strValue.length-1;i=0;
while(strValue.charAt(i++)==' ');
while(strValue.charAt(j--)==' ');
return strValue.substr(--i,++j-i+1);
}
function cleanup(fname)
{
    if((document.frmsubmit.mobile.value=='')&&(containsalph(document.frmsubmit.phone.value)==true) && fname=="mobile")
    {
        document.frmsubmit.elements[fname].value="";
    }
    else if(((document.frmsubmit.mobile.value=='')||(containsalph(document.frmsubmit.mobile.value)==true)||(foundstdcode(document.frmsubmit.mobile.value)==false)||(document.frmsubmit.mobile.value.length<10))&&((document.frmsubmit.phone.value=='')||(document.frmsubmit.phone.value=="Telephone No.")) && fname=="mobile")
    {
        document.frmsubmit.elements[fname].value="";
    }
    else
    {
        if(fname!="mobile")
        {
            document.frmsubmit.elements[fname].value="";
        }
    }
	
}
function recover(fname,value1)
{
	if(document.frmsubmit.elements[fname].value=="")
	{
		document.frmsubmit.elements[fname].value=value1;
	}
}
