//Functions to be kept as it is in the file. You will not have any use for these functions but even do not delete them as they are essential for the various validations functions declare below
function Trim(str){
while(str.charAt(0) == (" ") ){
str = str.substring(1);
}
while(str.charAt(str.length-1) == " " ){
str = str.substring(0,str.length-1);
}
return str;
}

function trimString(str) {
str= this != window? this : str;
return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}
//End of essential functions

//Function to check wheter the enetred field is numeric or not. It returns true if the field has only numeric data andreturns false id it has any other data
function numok(target,object)
{ var a=target.value;
	var b=isNaN(a);
	if (b==true)
	{alert("Kindly enter only numeric values. Alphanumeric Values are not allowed");
	 document.getElementById(object).value="";
	 return false;
	 }
	 else { 
	 return true;
	 }
}/*How to use
Call this function on the onBlur event of the text field
It has 2 parameters
1. this
2. name
Write the function as it is given below
For eg:
<input type="text" name="test" id="test" onblur="numok(this,name);" />*/

//Function to check whether the entered email is valid or not. It return true if it is valid and false incase the filed has an invalid email address
function validate_email(field,object)
{
with (Trim(field))
{
apos=value.indexOf("@")
dotpos=value.lastIndexOf(".")
if (apos<1||dotpos-apos<2) 
  {alert("Entered Email is not a valid Email. Kindly re-enter a valid Email");
	 document.getElementById(object).value="";
   return false; }
else return true; 
}
}/*How to Use
Call this function on the onBlur event of the text field
It has 2 parameters
1. this
2. name
Write the function as it is given below
For eg:
<input type="text" name="email" id="email" onblur="validate_email(this,name);" />*/

//Function to check an empty field. It returns false if the field is empty and true if not empty
function check_empty(field,msg)
{
if(Trim(document.getElementById(field).value)=="")
{
alert("Please Enter "+msg);
return false;
}
else return true;
}/*How to Use
Call this function in the ValidateForm function. It gets 2 parameters
1. Field Name
2. Message
function validate_reg_form()//Call this Function on the onclick event of the submit button and change the parameters accordingly
{
if(!check_empty("First_Name","First Name")) return false; 
if(!check_empty("Last_Name","Last Name")) return false; 
if(!check_empty("uname","User Name")) return false;
if(!check_empty("Password","Password")) return false; 
if(!check_empty("Password2","Confirm Password")) return false; 
if(!check_empty("Date_of_Birth","Date of Birth")) return false; 
if(!check_empty("Email","Email")) return false; 
if(!check_empty("State","State")) return false; 
if(!check_empty("City","City")) return false; 
if(!check_empty("Mobile_Number","Mobile Number")) return false; 
if(!check_empty("Phone_Number","Phone Number")) return false; 
if(!check_empty("Address","Address")) return false; 
if(!check_empty("amount","Amount")) return false; 
if(!check_empty("Balance","Balance")) return false; 
if(!check_empty("Occupation","Occupation")) return false;
if(!check_empty("sender_id","Sender ID")) return false;
else return true;
}*/

//Function to check Lenght of the text field. It return true if the length is as required else return false with the appropriate javascript alery message
function check_length(target,object,len,msg)
{
if(target.value!="") {
if(Trim(target.value).length<len) {
alert(msg+" should have atleast "+len+" Characters");
document.getElementById(object).value="";
return false;
}
else return true;
}
}/*How to Use 
Call this function the onBlur event of the text fields
1. It should have for parameters
	a. this
	b. name
	c. Length in number
	d. Message Name
For Example
<input type="text" name="uname" id="uname" onblur="check_length(this,name,5,'User Name')" />*/
