﻿// JScript File

function chktxtval1(val,str)
{
	if(str==0 && val.value=='')
	{
	    val.value='C.Code';
    }
    else if(str==1 && val.value=='C.Code')
    {
        val.value='';
    }	
}

function chktxtval2(val,str)
{
	if(str==0 && val.value=='')
	{
	    val.value='A.Code';
    }
    else if(str==1 && val.value=='A.Code')
    {
        val.value='';
    }	
}

function chktxtval3(val,str)
{
	if(str==0 && val.value=='')
	{
	    val.value='Phone Number';
    }
    else if(str==1 && val.value=='Phone Number')
    {
        val.value='';
    }	
}

function alphaValidate(incomingString, defaultValue)
{
	if(trimSpace(incomingString).length == 0 || incomingString.search(/[^a-zA-Z ]/g) != -1)
		return false;
	else
		return true;	
}


function trimSpace(x)
{
	var emptySpace = / /g;
	var trimAfter = x.replace(emptySpace,"");
	return(trimAfter);
}


function numberValidate(incomingString, defaultValue)
{
	if(trimSpace(incomingString).length == 0 || incomingString.search(/[^0-9]/g) != -1 || incomingString==defaultValue || parseInt(incomingString, 10) <= 0 )
		return false;
	else
		return true;	
}



function request()
{  
    if(document.getElementById('TextBox1').value=="")	
	{
	    alert("Please enter your Name");
	    document.getElementById('TextBox1').focus();
	    document.getElementById('TextBox1').select();
	    return false;
	}
	if (!alphaValidate(document.getElementById('TextBox1').value, 'First Name'))
	{
	    alert("Please enter your Name (alphabets only)");
	    document.getElementById('TextBox1').focus();
	    document.getElementById('TextBox1').select();
	    return false;
	}
	if (document.getElementById('TextBox2').value != "" && (!alphaValidate(document.getElementById('TextBox2').value, '')))
	{
	    alert("Please enter your Surname (alphabets only)");
		document.getElementById('TextBox2').focus();
		document.getElementById('TextBox2').select();
		return false;
	}
	if (document.getElementById('TextBox3').value != "" && (!alphaValidate(document.getElementById('TextBox3').value, '')))
	{
	    alert("Please enter your Company Name (alphabets only)");
	    document.getElementById('TextBox3').focus();
	    document.getElementById('TextBox3').select();
	    return false;
	}
	if (document.getElementById('DropDownList1').value == 0 || document.getElementById('DropDownList1').value == null) 
    {
        alert("Please select your Country Name");
        document.getElementById('DropDownList1').focus();
        return false;
    }

    if (document.getElementById('TextBox5').value != "" && (!alphaValidate(document.getElementById('TextBox5').value)))
	{
	    alert("Please enter your Job Function (alphabets only)");
	    document.getElementById('TextBox5').focus();
	    document.getElementById('TextBox5').select();
	    return false;
	}
	
	if(document.getElementById('TextBox6').value =="")
	{
	    alert("Please enter your email-id");
		document.getElementById('TextBox6').focus();
		document.getElementById('TextBox6').select();
		return false;
	}	
    
    var emailexp = /^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9\-]+)\.(([a-zA-Z]{2,}|[0-9]{2,})|([a-zA-Z]{2,}\.[a-zA-Z]{2,})|([a-zA-Z]{2,}\.[a-zA-Z]{2,}\.[a-zA-Z]{2,}))$/;
	if(trimSpace(document.getElementById('TextBox6').value)=="")
	{
	    alert("Please enter your correct email id");
	    document.getElementById('TextBox6').focus();
	    document.getElementById('TextBox6').select();
	    return false;
	}
	
	if(!emailexp.test(document.getElementById('TextBox6').value))
	{
	    alert("Please enter your correct email id");
	    document.getElementById('TextBox6').focus();
	    document.getElementById('TextBox6').select();
	    return false;
	}
	
	if(document.getElementById('TextBox7').value!= "" && (!numberValidate(document.getElementById('TextBox7').value)))
	{
	    alert("Please enter your Country Code (Numbers only)");
	    document.getElementById('TextBox7').focus();
	    document.getElementById('TextBox7').select();
	    return false;
	}
	
	if(document.getElementById('TextBox8').value!= "" && (!numberValidate(document.getElementById('TextBox8').value)))
	{
	    alert("Please enter your Area Code (Numbers only)");
	    document.getElementById('TextBox8').focus();
	    document.getElementById('TextBox8').select();
	    return false;
	}
	
	if(ddocument.getElementById('TextBox9').value!= "" && (!numberValidate(document.getElementById('TextBox9').value)))
	{
	    alert("Please enter your Phone Number (Numbers only)");
	    document.getElementById('TextBox9').focus();
	    document.getElementById('TextBox9').select();
	    return false;
	}
	
	
	    

	        var cked = false;
            for(i=0;i<rblist.length;i++) 
            {
                if(rblist[i].checked) 
                {
                    cked = true; 
                }
            }
            if(cked==false) 
            {                
                alert("Please Select a category query");             
                return false;
            }
	
	if(trimSpace(document.getElementById('TextBox10').value)=="" )
	{
	    alert("Please enter your comments");
	    document.getElementById('TextBox10').focus();
	    document.getElementById('TextBox10').select();
	    return false;
	}
	
	if((!alphaValidate(document.getElementById('TextBox10').value,'Phone Number')))
	    {
	        alert("Please enter your comments (alphabets only)");
	        document.getElementById('TextBox10').focus();
	        document.getElementById('TextBox10').select();
	        return false;
	    }
}


function requestmeeting() {

    

    if (trimSpace(document.getElementById('txtName').value) == "")
	{
		alert("Please enter your Name")
		document.getElementById('txtName').focus()
		document.getElementById('txtName').select()
		return false
	}
	if (!alphaValidate(document.getElementById('txtName').value, 'First Name'))
	{
		alert("Please enter your Name (alphabets only)")
		document.getElementById('txtName').focus()
		document.getElementById('txtName').select()
		return false
	}


	if (trimSpace(document.getElementById('txtDesignation').value) == "")
	{
		alert("Please enter your Designation")
		document.getElementById('txtDesignation').focus()
		document.getElementById('txtDesignation').select()
		return false
	}

	if (!alphaValidate(document.getElementById('txtDesignation').value, 'Designation'))
	{
		alert("Please enter your Designation (alphabets only)")
		document.getElementById('txtDesignation').focus()
		document.getElementById('txtDesignation').select()
		return false
	}


	if(document.getElementById('ddlDay').selectedIndex<0)
	{
		alert("Please select the date of meeting")
		document.getElementById('ddlDay').focus()
		return false
	}
	if (document.getElementById('ddlMonth').selectedIndex <= -1)
	{
		alert("Please select the month of meeting")
		document.getElementById('ddlMonth').focus()
		return false
	}
	if (document.getElementById('ddlYear').selectedIndex <= 0)
	{
		alert("Please select your year of meeting")
		document.getElementById('ddlYear').focus()
		return false
	}
	date = document.getElementById('ddlDay').options[document.getElementById('ddlDay').selectedIndex].text;
	month = document.getElementById('ddlMonth').options[document.getElementById('ddlMonth').selectedIndex].value;
	year = document.getElementById('ddlYear').options[document.getElementById('ddlYear').selectedIndex].text;
	if(year % 4 == 0)
	{	
		if(month =="2" && date >29)
		{
			alert("Please select the valid date of meeting")
			document.getElementById('ddlDay').focus()
			return false
		}
	}
	else if(month =="2" && date > 28)
	{
		alert("Please select the valid month of meeting")
		document.getElementById('ddlMonth').focus()
		return false
	}
	if(month =="4" || month =="6" || month =="9" || month =="11")
	{
		if(date >30)
		{
			alert("Please select the valid date of meeting")
			document.getElementById('ddlDay').focus()
			return false
		}
	}

	if (document.getElementById('txtemail').value == "")
	{
		alert("Please enter your email-id")
		document.getElementById('txtemail').focus()
		document.getElementById('txtemail').select()
		return false
	}	
    
    var emailexp = /^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9\-]+)\.(([a-zA-Z]{2,}|[0-9]{2,})|([a-zA-Z]{2,}\.[a-zA-Z]{2,})|([a-zA-Z]{2,}\.[a-zA-Z]{2,}\.[a-zA-Z]{2,}))$/;
    if (trimSpace(document.getElementById('txtemail').value) == "" )
	{
		alert("Please enter your correct email id")
		document.getElementById('txtemail').focus()
		document.getElementById('txtemail').select()
		return false
	}

	if (!emailexp.test(document.getElementById('txtemail').value))
	{
		alert("Please enter your correct email id")
		document.getElementById('txtemail').focus()
		document.getElementById('txtemail').select()
		return false
	}
	if (trimSpace(document.getElementById('txtContactNo').value) == "")
	{
		alert("Please enter your contact no.")
		document.getElementById('txtContactNo').focus()
		document.getElementById('txtContactNo').select()
		return false
	}

	if (!numberValidate(document.getElementById('txtContactNo').value, 'contact no'))
	{
		alert("Please enter a valid contact number")
		document.getElementById('txtContactNo').focus()
		document.getElementById('txtContactNo').select()
		return false
	}
	
}



function fillinfo()
{

    if (trimSpace(document.getElementById('TextBox1').value) == "")
	{
		alert("Please enter your Name")
		document.getElementById('TextBox1').focus()
		document.getElementById('TextBox1').select()
		return false
	}
	if (!alphaValidate(document.getElementById('TextBox1').value, 'First Name'))
	{
		alert("Please enter your Name (alphabets only)")
		document.getElementById('TextBox1').focus()
		document.getElementById('TextBox1').select()
		return false
	}

	if (document.getElementById('TextBox2').value != "" && (!alphaValidate(document.getElementById('TextBox2').value, '')))
	{
		alert("Please enter your Surname (alphabets only)")
		document.getElementById('TextBox2').focus()
		document.getElementById('TextBox2').select()
		return false
	}
	if (document.getElementById('TextBox3').value != "" && (!alphaValidate(document.getElementById('TextBox3').value, '')))
	{
		alert("Please enter your Company Name (alphabets only)")
		document.getElementById('TextBox3').focus()
		document.getElementById('TextBox3').select()
		return false
	}
	if (document.getElementById('TextBox5').value != "" && (!alphaValidate(document.getElementById('TextBox5').value, ''))) 
	{
	    alert("Please enter your Job Function (alphabets only)")
	    document.getElementById('TextBox5').focus()
	    document.getElementById('TextBox5').select()
	    return false
	}
	if (trimSpace(document.getElementById('TextBox4').value) == "")
	{
		alert("Please enter your email-id")
		document.getElementById('TextBox4').focus()
		document.getElementById('TextBox4').select()
		return false
	}	
    
    var emailexp = /^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9\-]+)\.(([a-zA-Z]{2,}|[0-9]{2,})|([a-zA-Z]{2,}\.[a-zA-Z]{2,})|([a-zA-Z]{2,}\.[a-zA-Z]{2,}\.[a-zA-Z]{2,}))$/;
    if (trimSpace(document.getElementById('TextBox4').value) == "")
	{
		alert("Please enter your correct email id")
		document.getElementById('TextBox4').focus()
		document.getElementById('TextBox4').select()
		return false
	}

	if (!emailexp.test(document.getElementById('TextBox4').value))
	{
		alert("Please enter your correct email id")
		document.getElementById('TextBox4').focus()
		document.getElementById('TextBox4').select()
		return false
	}


	if (document.getElementById('DropDownList1').value == 0 || document.getElementById('DropDownList1').value == null) 
    {
        alert("Please select your Country Name");
        document.getElementById('DropDownList1').focus();                 
        return false;
    }
}