﻿// JScript File

// JScript File

/* Form Validation Script for JOB BOARD
Developed By	: Rakesh
Date			: 4 Oct,2007
Message			: Create an array of form elements and apply validation rules on them.
*/
 var rulesrequest=new Array();
rulesrequest[0]='txtName:Your name|required';
rulesrequest[1]='txtCompany:Company name|required';
rulesrequest[2]='txtEmail:Email|required';
rulesrequest[3]='txtEmail|email|Invalid Email';
 rulesrequest[4]='txtPhone:Phone|required';
rulesrequest[5]='ddlPakage|required|Choose package to customize';
rulesrequest[6]='txtWebUrl:Web Url|url'
rulesrequest[8]='selHowFind|required|Select how you find us';
 rulesrequest[9]='formValidation()|custom';

  function formValidation() 
     {
             
			 if(document.getElementById("fileUpload").value!="")
			{
			    strFileName=document.getElementById("fileUpload").value
			    if (checkSpecialChar(strFileName)==false)
			    {
			       //alert("Special characters are not allowed in file")
			        document.getElementById("fileUpload").focus();
			        return "Special characters are not allowed in file.";
			    }
			    else
			    {
				    position=strFileName.lastIndexOf(".")+ 1
				    extension=strFileName.substring(position,strFileName.length)
				    extension=extension.toLowerCase()
				   if(extension != "txt" && extension != "xls" && extension != "zip" && extension != "pdf" && extension != "doc"  )
				    { 
				    //  alert("Please Select Only doc ,pdf,txt files can be attached.");
				       document.getElementById("fileUpload").focus();
			           return "Please Select Only doc, pdf, txt,xls, zip files can be attached.";
				    }
				    
                }					    
			}			    
    }
function checkSpecialChar(StatusText) {
		if (!(StatusText.indexOf('#') == -1)) {
			return false;
		} //For checking #
		if(!(StatusText.indexOf('+')==-1)) {
			return false;
		} //For checking +
		if(!(StatusText.indexOf('*')==-1)) {
			return false;
		} //For checking *
		if(!(StatusText.indexOf('&')==-1)) {
			return false;
		} //For checking &
		if(!(StatusText.indexOf('=')==-1)) {
			return false;
		} //For checking =
		if(!(StatusText.indexOf('?')==-1)) {
			return false;
		} //For checking ?
		if(!(StatusText.indexOf('%')==-1)) {
			return false;
		} //For checking %
		if(!(StatusText.indexOf("'")==-1)) {
			return false;
		} //For checking '
		return true;
	}
// rules[1]='txtName|alphaspace|Special character not allowed in Name';
//rules[3]='txtCompany|alphaspace|Special character not allowed in Company name';
//rules[7]='txtPhone|alphaspace|Special character not allowed in Name';


