2012-07-09 69 views
0

我使用javascript-coder.com中的gen_validatorv4.js來驗證表單。我喜歡它,因爲它設置爲正常使用非常簡單。但是現在我遇到了一個我無法修復的設置。使用javascript驗證表單字段gen_validatorv4.js

這就是我想要做的。我有一個表單用於編輯名稱,用戶名和密碼等字段的用戶。問題是我希望腳本僅在密碼字段不爲空時驗證密碼字段。

我已經試過這種方式,但它不工作:

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); 

任何想法的人?

Regards Per

回答

1

剛剛在ehow上發現了這個!

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