perqedelius
perqedelius

Reputation: 105

validate forms fields with javascript gen_validatorv4.js

I'm using gen_validatorv4.js from javascript-coder.com for validating forms. I love it because it's very simple to set up for normal use. But now I have run into a setup I can't fix.

This is what I'm trying to do. I have a form to edit users with fields for name, username and password etc. The problem is that I want the script to validate the password fields only when it's not empty.

I have tried this way but it doesn't work:

function DoCustomValidation() {
  var frm = document.forms["edit_validate"];
  if(frm.uPass.value != '') {

    frmvalidator.addValidation("uPass","minlen=8","Minimum 8 characters")
    frmvalidator.addValidation("uPass2","req","Passwords missing");
    frmvalidator.addValidation("uPass2","eqelmnt=uPass","Password fields doesn't match");
    frmvalidator.addValidation("uPass","neelmnt=uName","User name and password can't be the same");
    return true;

  } else {
    return false;
  }
}

frmvalidator.setAddnlValidationFunction(DoCustomValidation); 

Any Idea anyone?

Regards Per

Upvotes: 0

Views: 1539

Answers (1)

T Dizzle
T Dizzle

Reputation: 11

Just found this on ehow!

frmvalidator.addValidation("PASSWORD2","eqelmnt=PASSWORD", 
    "The confirmed password is not same as password");  

Upvotes: 1

Related Questions