[thelist] A little JS Problem

Norman Bunn norman.bunn at craftedsolutions.com
Tue Dec 28 16:33:12 CST 2004


I have this page with a very rudimentary password scheme 
(http://www.siconsultants.com/assoc.html).  It's kinda like those chain 
latches people put on doors; it will keep casual folks out.  In essence, 
it looks for a pattern in the password and allows the link to go through 
if there is a match.  If not, it generates an alert and sends you back 
to the same page.

My client likes this setup and is not worried about unauthorized access; 
all the really sensitive stuff is elsewhere.

However, he wants to make it so the casual observer cannot tell how many 
associations he has as clients and would like the password pattern to 
determine the page the user is routed to.  For example, type in 
"123abc_cpa" and go to the CPA page; type in "456def_bar" and go to the 
bar page.  I have tried to get this to work, but I can't seem to get the 
JS to override the ACTION in the FORM tag.  What am I missing?

The HTML:

<FORM METHOD=GET ACTION="cpa.html" NAME="cpaform" onSubmit="return cpaPass();">

THE JS:

<script language="JavaScript"> 
<!-- 
function cpaPass() { 
   var initArray = new Array("CPA","cpa","Cpa","CPa","cpA","cPA");
   var alertFlag = 0;
   var badInit = '1';
   if(document.cpaform.password.value == '') { 
      alert('Please enter your SCACPA password.'); 
	  return false;
   } 
   else{ 
      var passstr = document.cpaform.password.value; 
	  n=0;
	  while (n < initArray.length) {
	  	if (passstr.substring(7) == initArray[n]) {
		    badInit = '';
		}
	  	n++;
	  }
	  if (badInit != '') {
	  	alertFlag = 1;
	  }
      var passres = passstr.substr(0,3).match(/[0-9]/); 
      if(passres == null) { 
         alertFlag = 1; 
      } 
      passres = passstr.substr(3,3).match(/[A-Za-z]/); 
      if(passres == null) { 
         alertFlag = 1; 
      } 
      passres = passstr.substr(6,1).match(/_/); 
      if(passres == null) { 
         alertFlag = 1; 
      } 
   }
   if(alertFlag == 1) { 
      alert('The password you entered is invalid.\nPlease re-enter your SCACPA password.'); 
      return false; 
   } 
   else {
   return true;
   }
} 

Thanks!

Norman

-- 
---

Norman W. Bunn
norman.bunn at craftedsolutions.com
803.405.1008
----------------------------------------------
www.CraftedSolutions.com
Crafted Solutions, Inc.
Web Design & Development
Web Site Hosting & Custom Solutions
"Get the results the Internet promises;
 get the 'Net Result' from Crafted Solutions!"
----------------------------------------------




More information about the thelist mailing list