﻿/*
Revision History
------------------------------------------------------------------------------------
Date			Modified By			HPID	Comments
------------------------------------------------------------------------------------
08-Jun-09		Nagur				HP433	Radio Ad discount code feature.  
											Deleted the prefixes "DSC" in the discount code
19-Nov-09		Rajesh				HP458	Validations
------------------------------------------------------------------------------------
*/
function chk_form(){
		
		var x,discString,Disccode;
		x=Trim(document.frm1.txtDiscCode.value);
		pwd=Trim(document.frm1.txtPassword.value);
		document.frm1.txtuserid.value = Trim(document.frm1.txtuserid.value); 
		document.frm1.txtPassword.value = Trim(document.frm1.txtPassword.value);

		//HP458	Added the below code to validate the special characters in the userid
		var iChars = "!#$%^&*()+=-[]\';,~`/{}|\":<>?";   
		for (var i = 0; i < document.frm1.txtuserid.value.length; i++) 
			{   
				if (iChars.indexOf(document.frm1.txtuserid.value.charAt(i)) != -1)    
				{   	
				alert("Please remove the Invalid Characters in the UserID");
				document.frm1.txtuserid.focus();
				return false;  
				}  
			}   
		//End HP458
		
		if(Trim(document.frm1.txtuserid.value) == ''){
			alert("Please enter user name!!!") ;
			document.frm1.txtuserid.focus();
			return false;
		}
		//HP458 Deleted the Apostrophe validation below as it is included in validating special characters
		else if(Trim(document.frm1.txtPassword.value) == ''){
			alert("Please enter password!!!") ;
			document.frm1.txtPassword.focus();
			return false;
		}
		else if((pwd.length) < 6){
			alert('Password cannot be less than 6 characters') ;
			document.frm1.txtPassword.focus();
			return false;
		}
		//HP433:  Deleted the other condtion which checks for the DSC in the discount code

}

function valid_csr()
{
	sUname = document.frm1.txtuserid.value;
	sCsr = sUname.substring(sUname.length-4,sUname.length);
	if(sCsr == "_csr")
	{
		document.frm1.txtDiscCode.value="";
		document.getElementById("disccode").style.display="none";
	} 
	else 
	{
		document.getElementById("disccode").style.display="block";
	}
}













