function validation()
{
//Name validation
if(document.getElementById('FName').value.toUpperCase()=="FULL NAME")
{
  alert('Please Enter Your Name');

  document.getElementById('FName').focus();
  return false;
}

function trim(s)
{
  return s.replace(/^\s+|\s+$/, '');
}

//Email Validation
if(document.getElementById('Email').value.toUpperCase()=="EMAIL ID")
{
  alert('Please Enter Your Email id');
  document.getElementById('Email').focus();
  return false;
}

if (echeck(document.getElementById('Email').value)==false)
{

  document.getElementById('Email').focus()
  return false
}

//Phone Validation
if(document.getElementById('Phone').value.toUpperCase()=="PHONE")
{
  alert('Please Enter Your Phone');
  document.getElementById('Phone').focus();
  return false;
}

if(isNaN(document.getElementById('Phone').value)|| document.getElementById('Phone').value.length < 6)
{   
	alert('Phone should be numeric and greater than 6 digits');
	document.getElementById('Phone').focus();
	return false;
}


//date validation

//Course validation
if(document.getElementById('profession').selectedIndex==0)
{
  alert('Please select Profession');
  document.getElementById('profession').focus();
  return false;
   
}
if(document.getElementById('location').selectedIndex==0)
{
  alert('Please select Training Location');
  document.getElementById('location').focus();
  return false;
   
}
if(document.getElementById('ddl_courses').selectedIndex==0)
{
  alert('Please select course');
  document.getElementById('ddl_courses').focus();
  return false;
   
}
if(document.getElementById('courseformat').selectedIndex==0)
{
  alert('Please select Course Format');
  document.getElementById('courseformat').focus();
  return false;
   
}
if(document.getElementById('datep').value.toUpperCase()=="DATE")
{
  alert('Please Enter Your Date');

  document.getElementById('datep').focus();
  return false;
}


return true; 
}


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)==1 || 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					
}

function OnFocusFName()
{
 var txtFname=document.getElementById('FName');
 
 if(txtFname.value.toUpperCase()=="FULL NAME")
   txtFname.value='';
   
 return false;  
}

function OnBlurFName()
{
 var txtFname=document.getElementById('FName');
 
 if(txtFname.value.toUpperCase()=='')
   txtFname.value='Full Name';
   
 return false;  
}

function OnFocusEmail()
{
 var txtEmail=document.getElementById('Email');
 
 if(txtEmail.value.toUpperCase()=="EMAIL ID")
   txtEmail.value='';
   
 return false;  
}

function OnBlurEmail()
{
 var txtEmail=document.getElementById('Email');
 
 if(txtEmail.value.toUpperCase()=='')
   txtEmail.value='Email ID';
   
 return false;  
}

function OnFocusPhone()
{
 var txtPhone=document.getElementById('Phone');
 
 if(txtPhone.value.toUpperCase()=="PHONE")
   txtPhone.value='';
   
 return false;  
}

function OnBlurPhone()
{
 var txtPhone=document.getElementById('Phone');
 
 if(txtPhone.value.toUpperCase()=='')
   txtPhone.value='Phone';
   
 return false;  
}




function OnFocusComments()
{
 var txtComments=document.getElementById('Comments');
 
 if(txtComments.value.toUpperCase()=="QUESTIONS (IF ANY)")
  txtComments.value='';
   
 return false;  
}

function OnBlurComments()
{
 var txtComments=document.getElementById('Comments');
 
 if(txtComments.value.toUpperCase()=='')
   txtComments.value='Questions (if any)';
   
 return false;  
}


function OnFocusCompany()
{
 var txtCompany=document.getElementById('Company');
 
 if(txtCompany.value.toUpperCase()=="COMPANY")
   txtCompany.value='';
   
 return false;  
}

function OnBlurCompany()
{
 var txtCompany=document.getElementById('Company');
 
 if(txtCompany.value.toUpperCase()=='COMPANY')
   txtCompany.value='Company';
   
 return false;  
}

function OnFocusDate()
{
 var txtdate=document.getElementById('datep');
 
 if(txtdate.value.toUpperCase()=="DATE")
   txtdate.value='';
   
 return false;  
}

function OnBlurDate()
{
 var txtdate=document.getElementById('datep');
 
 if(txtdate.value.toUpperCase()=='')
   txtdate.value='Date';
   
 return false;  
}



 
      
