[thelist] A little JS Problem

Matt Warden mwarden at gmail.com
Tue Dec 28 17:14:24 CST 2004

Hi Norman,

On Tue, 28 Dec 2004 17:33:12 -0500, Norman Bunn
<norman.bunn at craftedsolutions.com> wrote:
> 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?

I'm not sure, but I did clean up your script some for you. Maybe you
can do a little testing with this and make sense of it? Something
tells me just the complexity of your script was making it hard to
debug (note, I didn't test this, but there shouldn't be anything but a
minor syntax error, if anything):

function cpaPass() {
  var status = '';

  // validate first
  if(document.cpaform.password.value == '') {
     status = 'nopass';

  // note, you probably don't have to test against null
  // here, but it's force of habit when calling a method on
  // an object i'm not sure is valid
  var passstr = document.cpaform.password.value;
  if (passstr == null || passstr.toLowerCase() != 'cpa') {
     status = 'badpass';

  var passres = passstr.substr(0,3).match(/[0-9]/);
  if(passres == null) {
     status = 'badpass';
  passres = passstr.substr(3,3).match(/[A-Za-z]/);
  if(passres == null) {
     status = 'badpass';
  passres = passstr.substr(6,1).match(/_/);
  if(passres == null) {
     status = 'badpass';

  // now, take action
  if(status == 'badpass') {
     alert('The password you entered is invalid.\nPlease re-enter your
SCACPA password.');
     return false;
  else if (status == 'nopass') {
     alert('Please enter your SCACPA password.');
     return false;
  else {
     return true;

Play around with this and if you still aren't getting it to work,
maybe you can offer a more narrowed-down description of the problem?

Matt Warden
Miami University
Oxford, OH

This email proudly and graciously contributes to entropy.

More information about the thelist mailing list