1
我有一個aspx頁面,其中有幾個文本框用於更改密碼。用戶輸入他們當前的密碼以及新的和確認的新密碼。我有一個取消按鈕和一個更改按鈕。如果點擊取消,則不會發生這是它應該做的事情。如果單擊更改並通過驗證,則應更改密碼,如果未驗證,則應顯示錯誤。我得到的問題是我使用的唯一的OnSubmit:true與我從www.livevalidation.com得到的LiveValidation js文件,我只希望點擊更改按鈕時觸發驗證。下面是我使用的腳本:使用LiveValidation單擊一個按鈕時,只有驗證失敗?
$(function() {
var currentPassword = new LiveValidation('<%= txtCurrentPassword.ClientID %>',
{validMessage: " " });
currentPassword.add(Validate.Presence,
{onlyOnSubmit: true,
failureMessage: "Required" });
var newPassword = new LiveValidation('<%= txtNewPassword.ClientID %>',
{validMessage: " " });
newPassword.add(Validate.Presence,
{onlyOnSubmit: true,
failureMessage: "Required" });
var confirmNewPassword = new LiveValidation('<%= txtConfirmNewPassword.ClientID %>',
{validMessage: " " });
confirmNewPassword.add(Validate.Presence,
{onlyOnSubmit: true,
failureMessage: "Required" });
confirmNewPassword.add(Validate.Confirmation,
{onlyOnSubmit: true,
match: '<%= txtNewPassword.ClientID %>',
failureMessage: "Your passwords don't match!" });
});