/*
   Script:                 PwdValidate.js

   Author:                 L. Jamieson

   Description:            Generic Password validation routine.

   Usage:                  Include this file with script tag and pass the value to be
                           validated to the function 'isProperPwd()'

			   This file can be included with the script tag
				   <script src="PwdValidate.js"></script>
				   '' added check for more than 12 characters

*/

//------------------------------------------------------------------------------------
// function: isProperPwd
//           Function to tell whether the given password is valid or not
//           
//------------------------------------------------------------------------------------
function isProperPwd(argPwd1,argPwd2,argPwdQ,argPwdAns) {
	var msg='';
	
	if (argPwd1.length < 6) msg+='Your password must be at least 6 characters long. \n';
	if (argPwd1.length > 12) msg+='Your password must be less than 12 characters long. \n';

	// check for one occurence of a-z and one occurence of 0-9
	var RegExp1 = /[a-z]/;
	var RegExp2 = /[0-9]/;
	var RegExp3 = /[_]/;
	var RegExp4 = /\W/;

	if (!(RegExp1.test(argPwd1) == true)) {
	            msg+='Password must contain at least one lowercase letter a-z.\n';
	            }
	if (!(RegExp2.test(argPwd1) == true)) {
		            msg+='Password must contain at least one digit 0-9.\n';
	            }
	if (RegExp4.test(argPwd1) == true | RegExp3.test(argPwd1) == true) {
		    msg+='Password must not contain special characters or spaces.\n';
		     }

	if (argPwd1 != argPwd2) msg+='The password and confirm password do not match. \n';

	if (argPwdQ == '') msg+='You must select a password hint question. \n'
	
	if (!(argPwdAns>'')) msg+='You must enter a password hint answer. \n'
	
	if (msg>'') {
		alert(msg);
		return (msg=='');
	      }
	else {
		return (msg=='');
		}

	}

//  End -->



