﻿// JScript File

// JScript File


 function validation()
{


var msg="";

//alert("hello");

if(document.getElementById("dnn_ctr433_Viewsupport_yourname").value=="")
{
msg="\n - Please fill in your name ";
}



if(document.getElementById("dnn_ctr433_Viewsupport_email").value=="")
{

////emailID.value=""
////emailID.focus()
msg += "\n - Please Fill in your Email Address ";

}

if(document.getElementById("dnn_ctr433_Viewsupport_email").value!="")
{
 if(echeck(document.getElementById('dnn_ctr433_Viewsupport_email').value)==false){
////emailID.value=""
////emailID.focus()
msg += "\n - Please input a valid email address! ";
}

}
//if(document.getElementById("dnn_ctr623_ViewCallback_request_PhoneNumber").value=="")
//{
//msg += "\n - Please enter Phone Number ";

//}
//if(document.getElementById("dnn_ctr623_ViewCallback_request_PhoneNumber").value!="")
//{
//var NumberToTest = document.getElementById("dnn_ctr623_ViewCallback_request_PhoneNumber").value;
//var IsFound = /^-?\d+$/.test(NumberToTest);
//if(IsFound==false)
//{
////// alert("Enter Valid Phone No.");
//msg += "\n - Invalid Phone No";

//}
//}

////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
}



