﻿// JScript File for User module

function ltrim (s)
    {
        return s.replace( /^\s*/, "" );
    }

function validate_Application()
{

var strName=ltrim(document.getElementById('txtName').value);
     if(strName=="")
        {
            alert("Enter your Name.");
            document.getElementById('txtName').focus();
            return false;
        }
         if (strName.length > 19)
      {         
         alert('Name can\'t be more than 20 characters');
         strName=strName.substr(0,20);
         document.getElementById('txtName').focus();
         return false;
      }    
        
var strContactNo=ltrim(document.getElementById('txtContactNo').value);        
        if(strContactNo=="")
        {
            alert("Enter your Contact Number.");
            document.getElementById('txtContactNo').focus();
            return false;
        }
        if(strContactNo!="")
	    {
	        if(!validateNumber(document.getElementById('txtContactNo')))
	        return false;
	    }
	      if (strContactNo.length > 19)
      {         
         alert('Contact Number can\'t be more than 20 Numbers');
         strContactNo=strContactNo.substr(0,20);
         document.getElementById('txtContactNo').focus();
         return false;
      }    
	    
	    var strEmail=ltrim(document.getElementById('txtEmail').value);        
	    if(strEmail=="")
        {
            alert("Enter your Email Id.");
            document.getElementById('txtEmail').focus();
            return false;
        }
          if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.form1.txtEmail.value)))
     {
			alert("Invalid Emailid Address! Correct it.")			
			document.getElementById('txtEmail').focus();
			return false;
     }
       
	
	var strExperience=ltrim(document.getElementById('txtExperience').value);        
	 if(strExperience=="")
        {
            alert("Enter your Experience.");
            document.getElementById('txtExperience').focus();
            return false;
        }
        
        if (strExperience.length > 19)
      {         
         alert('Experience can\'t be more than 20 characters');
         strExperience=strExperience.substr(0,20);
         document.getElementById('txtExperience').focus();
         return false;
      }     
        
           if(document.form1.ddlIndustry.selectedIndex == 0)
        {
            alert ( "Please select your Industry type." );
            return false;
        }  
        
         if(document.form1.flupResume.value =="")
		  {
			alert("Please upload your Resume.");
			document.form1.flupResume.focus();
			return false;
          } 
          /*if(document.form1.flupResume.value.length >=20)
		  {
			alert("Your file name should not be more than 20 characters.");
			alert(document.form1.flupResume.value.length);
//			document.form1.flupResume.focus();
			return false;
          }
          */ 
           if((document.form1.flupResume.value.lastIndexOf(".txt")==-1)&&(document.form1.flupResume.value.lastIndexOf(".doc")==-1) && (document.form1.flupResume.value.lastIndexOf(".rtf")==-1)&& (document.form1.flupResume.value.lastIndexOf(".pdf")==-1)) 
        {
        alert("Please attach only .doc,.rtf,.pdf,.txt files only");
        document.form1.flupResume.value=""
        document.form1.flupResume.focus();
        return false;
        }
return true;

        
}


function validateNumber(fieldValue)
	{
	    var valid = " 1234567890-+"
	    var ok = "yes";
	    var temp;
	     if(fieldValue.value.indexOf("-")==0)
	        {
	          ok="no";
	        }
	    for (var i=0; i<fieldValue.value.length; i++)
	    {
	       temp = "" + fieldValue.value.substring(i, i+1);
	       if (valid.indexOf(temp) == "-1") ok = "no";
	    }
	    if (ok == "no")
	    {
	       alert("Invalid entry! Only Numbers are accepted!");
	       fieldValue.select();
	       fieldValue.focus();
	       return false;
	    }
	    return true;
	}


