
function isValidAmount(element,msg,required)

{

var ele=element;

var mess=msg;

var req = trim(required);

var inc = element.value;

if(inc == "")

	{

		var rval = trim(required);

		if (rval.toLowerCase() == "yes" || rval == 1)

		{

			alert("Please enter "+msg);

			element.focus();

			return false;

		}

	}

	if(inc!="")

	{

	   if(inc.indexOf('.')>=0)

	   {

		   var len = inc.substring(inc.indexOf('.'),inc.length);

		  

		   if(len.length == 3)

		   {

			  var flag=0;

		   }

		   else

		   {

		     alert("Please enter valid "+msg);

			 element.focus();

			 return false;

		   }

	   }

	   else

	   {

		 var flag=0;

  	   }

	   if(flag==0)

	   {

	    if(!isValidPrice(ele,mess,req))

		return false;

		}

	  }

	  return true;

	}// end for amount validation

	

function trim(strText) { 

    // this will get rid of leading spaces 

    while (strText.substring(0,1) == ' ') 

        strText = strText.substring(1, strText.length);



    // this will get rid of trailing spaces 

    while (strText.substring(strText.length-1,strText.length) == ' ')

        strText = strText.substring(0, strText.length-1);



   return strText;

} 



/*

1. PHONE NUMBER VALIDATION

Usage: 

Element  name of the control, like frm.phone

Message  Field Name that we want to display in alert message.

Required  Set this to yes if the field is mandatory, otherwise no.



 if(!isValidPhone(frm.phone,'Phone Number','yes'))

 return;

*/

function isValidPhone(element, msg, required)

{	

	var VarPhone = element.value;

	if (VarPhone== "")

	{	

		var rval = trim(required);

		if (rval.toLowerCase() == "yes" || rval == 1)

		{

			alert("Please enter "+msg);

			element.focus();

			return false;

		}

	}

	if (VarPhone != "")

	{

		var Phno;

		Phno=VarPhone;

		var valid = "-0123456789()";

		var hyphencount = 0;

		for (var i=0; i < Phno.length; i++) 

		{

			temp = "" + Phno.substring(i, i+1);

			if (valid.indexOf(temp) == "-1")

			{

				alert("Invalid characters in your "+msg+". Please try again.");

				element.focus();

				return false;

			}

		}

     } 

	 return true;      

}



/*

2. NUMBER VALIDATION

Usage:

Element  name of the control, like frm.number

Message  Field Name that we want to display in alert message.

Required  Set this to yes if the field is mandatory, otherwise no.



 if(!isValidNumber(frm.num,'Roll Number','yes'))

 return;

*/

function isValidNumber(element, msg, required)

{  

	var VarNumber = element.value;

	if(VarNumber == "")

	{

		var rval = trim(required);

		if (rval.toLowerCase() == "yes" || rval == 1)

		{

			alert("Please enter "+msg);

			element.focus();

			return false;

		}

	}

	if (VarNumber != "")

	{

		var Num;

		Num=VarNumber;

		var valid = "0123456789";

		var hyphencount = 0;

		

		for (var i=0; i < Num.length; i++) 

		{

			temp = "" + Num.substring(i, i+1);

			if (valid.indexOf(temp) == "-1")

			{

			  alert("Invalid characters in your "+msg+".  Please try again.");

			  element.focus();

			  return false;

			}

	   } // end for loop

	   

		if(VarNumber < 1)

		{

			alert(msg+" is not a valid number");

			element.focus();

			return false;

		}

    }   // end if

    return true; 

}  // end function



/*

3. EMAIL ADDRESS VALIDATION



Usage: 

Element  name of the control, like frm.email

Required  Set this to yes if the field is mandatory, otherwise no.



	 if(!isValidEmail(frm.email,'yes'))

	 return;

*/



function isValidEmail(element, required)

{

	var VarEmail = element.value;

	if(VarEmail == "")

	{

		var rval = trim(required);

		if (rval.toLowerCase() == "yes" || rval == 1)

		{

			alert("Please enter Email ID");

			element.focus();

			return false;

		}

	}	

	if(VarEmail != "")

	{

		var emailStr = VarEmail;

		 

		var emailPat=/^(.+)@(.+)$/

		var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"

		var validChars="\[^\\s" + specialChars + "\]"

		var firstChars=validChars

		var quotedUser="(\"[^\"]*\")"

		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/

		var atom="(" + firstChars + validChars + "*" + ")"

		var word="(" + atom + "|" + quotedUser + ")"

		var userPat=new RegExp("^" + word + "(\\." + word + ")*$")

		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")

		var matchArray=emailStr.match(emailPat)

		if (matchArray==null) 

		{

			 alert("Email address seems to be incorrect (check @ and .'s)");

			 element.focus();

			 return false;

		}

		var user=matchArray[1]

		var domain=matchArray[2]

		if (user.match(userPat)==null) 

		{

			alert("The username doesn't seem to be valid.");

			element.focus();

			return false;

		}

		var IPArray=domain.match(ipDomainPat)

		if (IPArray!=null) 

		{

			for (var i=1;i<=4;i++) 

			{

				if (IPArray[i]>255) 

				{

					 alert("Destination IP address is invalid!");

					 element.focus();

					 return false;

				}

			}

		}

		var domainArray=domain.match(domainPat)

		if (domainArray==null) 

		{

			alert("The domain name doesn't seem to be valid.");

			element.focus();

			return false;

		}

		var atomPat=new RegExp(atom,"g");

		var domArr=domain.match(atomPat);

		var len=domArr.length;

		if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3) 

		{

		   alert("The address must end in a three-letter domain, or two letter country.");

		   element.focus();

		   return false;

		}

		if (domArr[domArr.length-1].length==2 && len<3) 

		{

			var errStr = "This address ends in two characters, which is a country";

			errStr    += " code.  Country codes must be preceded by ";

			errStr	  += "a hostname and category (like com, co, pub, pu, etc.)";

			alert(errStr);

			element.focus();

			return false;

		}

		if (domArr[domArr.length-1].length==3 && len<2) 

		{

			 var errStr="This address is missing a hostname!";

			 alert(errStr);

			 element.focus();

			 return false;

		}

	}

	return true;

}



/* 

4. ZIPCODE/PINCODE  VALIDATION



Usage:

	Element  name of the control, like frm.zipcode

	Required  Set this to yes if the field is mandatory, otherwise no.



	if(!isValidZipcode(frm.zip,'yes'))

	return;

*/

function isValidZipcode(element,required) 

{

	var valid = "0123456789-";

	var hyphencount = 0;

	var field = element.value;

	var str   = required;

	if(field == "")

	{

		var rval = trim(required);

		if (rval.toLowerCase() == "yes" || rval == 1)

		{

			alert("Please enter ZipCode");

			element.focus();

			return false;

		}

	}	

	if (field != "")

	{

		if (field.length!=6 && field.length!=5 && field.length!=10) 

		{

			alert("Zip code length should be  5 (without hyphens) or 10 with Including Hyphens ( for USA)....");

			element.focus();

			return false;

		}

		for (var i=0; i < field.length; i++) 

		{

			temp = "" + field.substring(i, i+1);

			if (temp == "-") hyphencount++;

			if (valid.indexOf(temp) == "-1")

			{

				alert("Invalid characters in your zip code.  Please try again.");

				element.focus();

				return false;

			}

			if ((hyphencount > 1) || ((field.length==10) && "" + field.charAt(5)!="-")) 

			{

				alert("The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.   Please try again.");

				element.focus();

				return false;

			}

		}

	}

	return true;

}



/*

5. ALPHA VALIDATION

//to find if the field contains alphabets only

usage:

Element  name of the control, like frm.firstname

Message  Field Name that we want to display in alert message.

Required  Set this to yes if the field is mandatory, otherwise no.



 if(!isValidAlphabet(frm.firstname,'First Name','yes'))

 return;

*/



function isValidAlphabet(element, msg, required)

{

	var i=0;

	var ValidData="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz._- ";

	var Data=element.value;

	if(element.value == "")

	{

		var rval = trim(required);

		if (rval.toLowerCase() == "yes" || rval == 1)

		{

			alert("Please enter "+msg);

			element.focus();

			return false;

		}

	}	

	if(element.value != "")

	{

		for(i=0;i<Data.length;i++)

		{

			if(ValidData.indexOf(Data.charAt(i))==-1)

			{

				alert("PLease enter Non-Numeric Data Only");

				element.focus();

				return false;

			}

		}

	}

    return true;

}



/*

6. ALPHANUMERIC VALIDATION

//to check if the field contains both alphabets and numbers

usage:

Element  name of the control, like frm.firstname

Message  Field Name that we want to display in alert message.

Required  Set this to yes if the field is mandatory, otherwise no.



 if(!isValidAlphaNumeric(frm.firstname,'First Name','yes'))

 return;

*/



function isValidAlphaNumeric(element, msg, required)

{

	var i=0;

	var ValidData=". ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890/_- ";

	var Data=element.value;

	

	if(element.value == "")

	{

		var rval = trim(required);

		if (rval.toLowerCase() == "yes" || rval == 1)

		{

			alert("Please enter "+msg);

			element.focus();

			return false;

		}

	}	

	if(element.value != "")

	{

		for(i=0;i<Data.length;i++)

		{

			if(ValidData.indexOf(Data.charAt(i))==-1)

			{

				alert("Invalid entry.\t\t");

				element.focus();

				return false;

			}

		}

	}

	return true;

}



/*

7. URL VALIDATION



Usage:

Element  name of the control, like frm.url

Message  Field Name that we want to display in alert message.

Required  Set this to yes if the field is mandatory, otherwise no.



	 if(!isValidURL(frm.url, "URL", "yes")) 

	 return;

*/

function isValidURL(element, msg, required)

{

	if(element.value == "")

	{

		var rval = trim(required);

		if (rval.toLowerCase() == "yes" || rval == 1)

		{

			alert("Please enter "+msg);

			element.focus();

			return false;

		}

	}

	if(element.value != "")

	{

		var oRegExp = /[^:]+:\/\/[^:\/]+(:[0-9]+)?\/?.*/;

		if (!oRegExp.test(element.value))

		{

			alert('\r\n The URL you have entered is invalid.\n Please check it for accuracy.');

			element.focus();

			element.select();

			return false;

		}

	}

	return true;

}



/*

8. DATE VALIDATION



Usage:

Element  name of the control, like frm.date

Message  Field Name that we want to display in alert message.

Required  Set this to yes if the field is mandatory, otherwise no.



Valid date formats are MM-DD-YYYY, MM/DD/YYYY and MM.DD.YYYY  



	 if(!isValidDate(frm.startdate, "Started Date", "yes")) 

	 return;

*/

function isValidDate(element, msg, required) 

{

	var dateStr = element.value;

	var valid = "0123456789-/.";

	var temp = "";

	var hyphencount = 0 ;

	var slashcount = 0 ;

	var dotcount = 0 ;

	if(element.value == "")

	{

		var rval = trim(required);

		if (rval.toLowerCase() == "yes" || rval == 1)

		{

			alert("Please enter "+msg);

			element.focus();

			return false;

		}

	}

	if(element.value != "")

	{

		for (var i=0; i < dateStr.length; i++)

		{

			temp = "" + dateStr.substring(i, i+1);

			 if  (temp == "-")  { hyphencount++; }

				else  if (temp == "/")  {  slashcount++; }

				   else  if (temp == ".") { dotcount++; }

			if ( ( hyphencount == 2 ) || ( slashcount == 2 ) || ( dotcount == 2 ) )

			{

				t=dateStr.substring(6,10);

				if(t.length==4)

				{

					if(t<1900)

					 {

						alert("the century of date should be greater than or equal to 1900.");

						element.focus();

						return false;

					 }

				}

			}          

			if (valid.indexOf(temp) == "-1")

			{

				alert("Invalid characters in your date.  Please try again.");

				element.focus();

				return false;

			}

		} //end of for loop   

		//alert ( "hyphen  " + hyphencount + " slash " + slashcount + " dot " + dotcount )  ; 

		if ( ( hyphencount== 2) & (slashcount !=2) && (dotcount !=2) ) {}

		else if ( ( hyphencount!= 2) & (slashcount ==2) && (dotcount !=2) ) {}

		else if ( ( hyphencount!= 2) & (slashcount !=2) && (dotcount ==2) ) {}

		else 

		{	

			alert("The hyphen character should be used with a properly formatted. Please try again.");

			element.focus();

			return false;

		}

		   

		if (dateStr.length == 8 || dateStr.length == 10 )

		{

			var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/;

			var matchArray = dateStr.match(datePat); // is the format ok?

			if (matchArray == null) 

				return true;

	

			month = matchArray[1]; // parse date into variables

			day = matchArray[3];

			year = matchArray[4];

			//alert(matchArray[1]);

			//alert(matchArray[3]);

			//alert(matchArray[4]);

			

			if (month < 1 || month > 12) 

			{ // check month range

				alert("Month must be between 1 and 12.");

				element.focus();

				return false; 

			}

			if (day < 1 || day > 31) 

			{

				alert("Day must be between 1 and 31.");

				element.focus();

				return false; 

			}

			if ((month==4 || month==6 || month==9 || month==11) && day==31) 

			{

				alert("Month "+month+" doesn't have 31 days!")

				element.focus();

				return false; 

			}

			if (month == 2) 

			{ // check for february 29th

				var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));

				if (day>29 || (day==29 && !isleap))

				{

					alert("February " + year + " doesn't have " + day + " days!");

					element.focus();

					return false;

				}

			} // end of month = 2 condition

		} // end of date string length = 8 or length = 10 condition

		else 

		{

		   alert("Entered date is invalid format, Date should be 8 to 10 chars. length.");

		   element.focus();

		   return false;

		} 

	}

	return true;  // date is valid

}



/*

9. SELETC VALIDATION



Usage:

Element  name of the control, like frm.firstname

Message  Field Name that we want to display in alert message.



if(!isValidSelect(frm.country,'Country'))

return;

*/

function isValidSelect(element,msg) 

{

	if(element.value == "0") 

	{

		alert("Please select "+msg+" from the list");

		element.focus();

		return false;

	}

	return true;

}



/*

10. FUNTION SELECTALL CHECK BOXES



Usage:

frm  name of the form



SelectAll(frm);

*/



function SelectTAll(frm) 

{

   if(frm.tall.checked == true) 

   {

	 for(i=0;i<frm.elements.length;i++) 

	 {

	   if((frm.elements[i].type == "checkbox") && (frm.elements[i].name != "tall")) 

	   {

		 frm.elements[i].checked = true;

	   } // if statement

	 } // for loop

   }

   else if(frm.tall.checked == false) 

   {

	  for(i=0;i<frm.elements.length;i++) 

	  {

		 if((frm.elements[i].type == "checkbox") && (frm.elements[i].name != "tall")) 

		 {

		   frm.elements[i].checked = false;

		 } // if statement

	  } // for loop

   } // if - else - if condition

} // closing the function SelectAll()



/*

11. IS LEAP YEAR



Usage:  Y  year

If the given year is a leap year, this function will return true. otherwise false.

isLeapYear('2004');



*/

function isLeapYear(y) 

{

	if( y % 4 == 0) 

	{

		if( y % 100 == 0 ) 

		{

			if( y % 400 == 0) 

			{

				return true;

			}

			else 

			{

				return false;

			}

		}

		else 

		{

			return true;

		}

	}

	else 

	{

		return false;

	}

} // closing the function isLeapYear()



/*

12. CONFIRM PASSWORD



Usage:

Element1 name of the first control like frm.password.

Element2 name of the second control like frm.confirmpassword.



if(!isValidConfirmPassword(frm.pwd, frm.conpwd))

return;

*/

function isValidConfirmPassword(element1,element2) 

{

	if(element1.value != element2.value)

	{

		alert("Confirm Password doesn't match");

		element2.focus();

		return false;

	}

	else

		return true;

} // closing the function PassValidation()



/*

13. GET COUNT OF



Usage:

This can be used for any character validation.

For example in a valid date the count of - or / should not be more than 2

Likewise in a valid numer there should be only one.



*/

function getCountOf(vChr, txt)

{

	var i = 0;

	var iCount = 0;

	for( i=0; i < txt.length; i++ )

	{

		if( txt.charAt(i) == vChr )

		{

			iCount++;

		}

	}

	return iCount;

}



/*

14. IS BLANK

To check if trim(value) is blank

Usage:

	This fucntion can be used to check if a given text contains only spaces or 0 in length.



	INPUT: Text [txt]

				Minimum Length [minlen] optional

				Indicates that the text should be atleast 'minlen' in length



	OUTPUT: returns true if blank else false



*/	

function isBlank(txt, minlen)

{

	if(txt.length == getCountOf('\n', txt))

	{

		// This condition avoids the entry of just newlines in text areas.

		return true;

	}

	if( txt.length == getCountOf(' ', txt) || txt.length == 0 )

	{

		return true;

	}

	else if( minlen > 0 )

	{

		if( txt.length < minlen )

		{

			return true;

		}

		else

		{

			return false;

		}

	}

	else

	{

		return false;

	}

	return true;

}



/*

15. INCLUDE SPECIAL CHARACTER



In some cases, we want to validate whether a given value contains at 

least one special character or not. Below mentioned function will be useful 

for such situations.



Usage:

	Element  name of the control like frm.password.

	Message  Field Name that we want to display in alert message.



if(!isSplchar(frm.pwd, "Password"))

return;

*/

function isSplchar(element, msg)

{

	var alp = '!@#$%&*_1234567890';

	var count = 0;

	for (var i=0;i<element.value.length;i++)

	{

		temp=element.value.substring(i,i+1);

		if (alp.indexOf(temp)!= -1)

		{

			count = 1;

		}

	} // closing the for loop

	if(count == 0)

	{

	  alert(msg+" should contain atleast one special character (!,@,#,$,%,&,*, _  and numbers can be used).");

	  element.focus();

	  return false;

	}

	return true;

}

 

/*

16. isValidEntry



Usage:

	Element  name of the control like frm.password.

	Message  Field Name that we want to display in alert message.



if(!isValidEntry(frm.name, "Name"))

return;

*/

function isValidEntry(element,msg) 

{

	if(element.value.length == 0)

	{

		alert("Please enter "+ msg);

		element.focus();

		return false;

	}

	else if(isBlank(element.value))

	{

		alert("Please enter "+ msg);

		element.focus();

		return false;

	}

	return true;

} // closing the function GenValidation()



/*

17.  FUNCTION SPLCHARACTERS(element)

No speaicl Characters

This function will not accept any special characters.

Valid entries for this function are [a-z][A-Z][0-9][ _ ].

Usage:

	Element  name of the control like frm.password.



if(!noSplChars(frm.name))

return;

*/



function noSplChars(element) 

{

	var alp = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";

	for (var i=0;i<element.value.length;i++)

	{

		temp=element.value.substring(i,i+1);

		if (alp.indexOf(temp)==-1)

		{

			alert("No special characters\r\nValid entries are [a-z][A-Z][0-9][ _ ]");

			element.focus();

			return false;

		}

	} // closing the for loop

	 return true;

} // closing the function SplCharacters()



/*

18. SplCharactersSpace

Valid entries for this function are [a-z][A-Z][0-9][ space ].

Usage:

	Val  specify the value which we are going to validate.



if(!noSplCharsExSpace(frm.name.value))

return;

*/	

function noSplCharsExSpace(Val)

{

	var alp = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ";



	for (var i=0;i<Val.value.length;i++){

		temp=Val.value.substring(i,i+1);

		if (alp.indexOf(temp)==-1){

			alert("No special characters \nValid entries are [a-z][A-Z][0-9][ space ]");

			Val.focus();

			return false;

		}

	} // closing the for loop

	return true;

} // closing the function SplCharactersSpace()



/*



19. FUNCTION SPLNUMBERS(element) 



if(!SplNumbers(frm.num.value))

return;

*/

	

function SplNumbers(Val)

{

	var alp = "0123456789+-";

	for (var i=0;i<Val.value.length;i++)

	{

		temp=Val.value.substring(i,i+1);

		if (alp.indexOf(temp)==-1)

		{

			alert("No special characters \nValid entries are [0-9][ + - ]");

			Val.focus();

			return false;

		}

	} // closing the for loop

	return true;

} // closing the function SplNumbers()



/*

20.

	This function checks if the characters in a given text are part of a given character set.



	INPUT:	Text ti be verified [txt]

				String of character that forms the reference [charset]



	OUTPUT: Returns true if all of the characters in txt are part of charset, else false.



	USAGE:

	for example:



		checkInCharSet( "guru", "aeiouAEIOU" ) this fucntion returns false as "guru" contains 'g' and 'r'

		whcih are not part of "aeiouAEIOU".



		checkInCharSet( "abC", "abcdefABCDEF" ) this statement returns true as all "abC" contains characters

		that are present in "abcdefABCDEF"

*/

function checkInCharSet(txt, charset)

{

	var b = true;

	for(i = 0; i < txt.length; i++ )

	{

		if( charset.indexOf(txt.charAt(i)) == -1 )

		{

			b = false;

		}

	}

	return b;

}



/*

21. GET SELECTED INDEX

This can used while validating radio button groups. 

If none of the buttons is selected then the function	

returns -1 else the id.



E.g: frm is the name of a form and radSearchType is the radiobutton group name.



if( getSelectedIndex(frm.radSearchType) == -1 )

{

	alert("Please select search type." );

	frm.radSearchType[0].focus();

	return;

}



*/

function getSelectedIndex(radgroup)

{

	/* Returns back the id of selected radio button in a radio button group  */

	var j = -1;

	

	if(radgroup.length)   

	{

		for( i=0; i < radgroup.length; i++ )

		{

			if(radgroup[i].checked)

			{

				j = i;

			}

		}

	}

	return j;

}



/*

22. TextareaValidation(elem,msg,len)

This function can be used to validate the length of Text area's in forms.

For example...if the value of text area should not exceed 500 characters.



Arguments :

elem : The element(TextArea)

msg : Message to be alerted

	  For example "Description"

len : Noof characters not to be exceeded



E.g: frm is the name of a form and desc is a text area name.



Usage in form: 

if(!isValidTextarea(frm.desc,'Description',500))

return;

*/



function isValidTextarea(elem,msg,len) 

{

	if(elem.value.length == 0)

	{

		if(isBlank(elem.value,len)) 

		{

			alert("Please enter "+msg);

			elem.focus();

			return false;

		}

	}

	if(elem.value.length > len) 

	{

		alert(msg+" should not exceed "+len+" characters");

		elem.focus();

		return false;

	}	

	

	return true;

} // closing the function TextareaValidation()



	/**

	 FUNCTION GENVALIDATION(element.message1,message2,spl) 

	 **/

	

	function GenValidation(Element,MessageLen0,MessageLen4,spl) {

		

		if(MessageLen0.length != 0)

		{

			if(Element.value.length == 0)

			{

				alert("You must enter "+ MessageLen0+".");

				Element.focus();

				return 0;

			}

			else if(isBlank(Element.value))

			{

				alert("You must enter "+ MessageLen0+".");

				Element.focus();

				return 0;

			}

		}

	

		if(MessageLen4.length != 0)

		{

			if(Element.value.length < 4)

			{

				alert( MessageLen4 + " should be more than 4 characters");

				Element.focus();

				return 0;

			} // closing the if - else condtion for if(MessageLen4.length != 0)

		}

	

		if(spl == "spl")

		{

			if(SplCharacters(Element) == 0)

			return 0;

		}

		else if(spl == "space")

		{

			if(SplCharactersSpace(Element) == 0)

			return 0;

		}

	} // closing the function GenValidation()



function isValidPrice(element, msg, required)

{  

	var VarNumber = element.value;

	if(VarNumber == "")

	{

		var rval = trim(required);

		if (rval.toLowerCase() == "yes" || rval == 1)

		{

			alert("Please enter "+msg);

			element.focus();

			return false;

		}

	}

	if (VarNumber != "")

	{

		var Num;

		Num=VarNumber;

		var valid = "0123456789.";

		var hyphencount = 0;

		

		for (var i=0; i < Num.length; i++) 

		{

			temp = "" + Num.substring(i, i+1);

			if (valid.indexOf(temp) == "-1")

			{

			  alert("Invalid characters in your "+msg+".  Please try again.");

			  element.focus();

			  return false;

			}

	   } // end for loop

	   

		if(VarNumber < 1)

		{

			alert(msg+" is not a valid number");

			element.focus();

			return false;

		}

    }   // end if

    return true; 

}  // end function



<!--

function MM_swapImgRestore() { //v3.0

  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;

}



function MM_preloadImages() { //v3.0

  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();

    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)

    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}

}



function MM_findObj(n, d) { //v4.01

  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];

  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);

  if(!x && d.getElementById) x=d.getElementById(n); return x;

}



function MM_swapImage() { //v3.0

  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)

   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}

}





function verifyPwd(frm)

{

	/*if( isBlank(frm.oldpwd.value, 4) )

	{

		alert("Passwords should be minimum 4 characters in length.");

		frm.oldpwd.focus();

		return false;

	}*/



	if( isBlank(frm.newpwd.value, 4) )

	{

		alert("Passwords should be minimum 4 characters in length.");

		frm.newpwd.focus();

		return false;

	}



	if( !checkInCharSet(frm.newpwd.value, "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") )

	{

		alert("Only alphanumeric characters are allowed for passwords.");

		frm.newpwd.focus();

		return false;

	}



	if( frm.newpwd.value != frm.newpwd1.value )

	{

		alert("New Password and Confirm New Password should be same.");

		frm.newpwd1.focus();

		return false;

	}



	if( frm.newpwd.value == frm.oldpwd.value )

	{

		alert("Please choose a password which is different from Old Password.");

		frm.newpwd.focus();

		return false;

	}



	return true;

}

//-->

