﻿// JScript File


 function validation()
{


var msg="";

//alert("hello");

if(document.getElementById("dnn_ctr435_Viewquickcontact_edata_firstname").value=="")
{
msg="\n - Please enter Name ";
}


if(document.getElementById("dnn_ctr435_Viewquickcontact_edata_email").value=="")
{

////emailID.value=""
////emailID.focus()
msg += "\n - Please enter email address ";

}

if(document.getElementById("dnn_ctr435_Viewquickcontact_edata_email").value!="")
{
 if(echeck(document.getElementById('dnn_ctr435_Viewquickcontact_edata_email').value)==false){
////emailID.value=""
////emailID.focus()
msg += "\n - Incorrect Emailid ";
}

}

if(document.getElementById("dnn_ctr435_Viewquickcontact_edata_telephone").value!="")
{
var NumberToTest = document.getElementById("dnn_ctr435_Viewquickcontact_edata_telephone").value;
var IsFound = /^-?\d+$/.test(NumberToTest);
if(IsFound==false)
{
//// alert("Enter Valid Phone No.");
msg += "\n - Invalid Phone No";

}
}
if(document.getElementById("dnn_ctr435_Viewquickcontact_edata_mobile").value=="")
{
msg += "\n - Please enter Mobile Number ";

}
if(document.getElementById("dnn_ctr435_Viewquickcontact_edata_mobile").value!="")
{
var NumberToTest = document.getElementById("dnn_ctr435_Viewquickcontact_edata_mobile").value;
var IsFound = /^-?\d+$/.test(NumberToTest);
if(IsFound==false)
{
//// alert("Enter Valid Mobile No.");
msg += "\n - Invalid Mobile No";

}
}
if(document.getElementById("dnn_ctr435_Viewquickcontact_edata_fax").value!="")
{
var NumberToTest = document.getElementById("dnn_ctr435_Viewquickcontact_edata_fax").value;
var IsFound = /^-?\d+$/.test(NumberToTest);
if(IsFound==false)
{
//// alert("Enter Valid Fax no.");
msg += "\n - Invalid Fax no";

}
}

if(document.getElementById("dnn_ctr435_Viewquickcontact_edata_website").value!="")
{
if ((document.getElementById("dnn_ctr435_Viewquickcontact_edata_website").value.indexOf("http://") == -1) ||
(document.getElementById("dnn_ctr435_Viewquickcontact_edata_website").value.indexOf(".") == -1)) {
msg += "\n - Invalid Web site";
}
}



////alert(document.getElementById("dnn_ctr623_ViewCallback_request_selectDepartment").value)

//if(document.getElementById("dnn_ctr623_ViewCallback_request_selectDepartment").value=="0")
//{
//msg += "\n - Please select the department ";

//}
//if(document.getElementById("dnn_ctr623_ViewCallback_request_Subject").value=="")
//{
//msg +="\n - Please enter Subject ";
//}




if(msg!="")
{
alert(msg);
return false;
}


else
{ 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)==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
}
