I have an aspx page which has a few textboxes used to change a password. The user types in their current password along with a new and a confirmed new password. I have a cancel button and a change button. If cancel is clicked, nothing happens which is what it is supposed to do. If change is clicked and validation is passed, it should change the password and if it does not validate, it should display errors. The problem I am getting is that I am using the onlyOnSubmit : true with the LiveValidation js file which I got from www.livevalidation.com and I only want the validation to fire when the Change button is clicked. Here is the script I am using:
$(function() {
var currentPassword = new LiveValidation('<%= txtCurrentPassword.ClientID %>',
{validMessage: " " });
currentPassword.add(Validate.Presence,
{onlyOnSubmit: true,
failureMessage: "Required" });
var newPassword = new LiveValidation('<%= txtNewPassword.ClientID %>',
开发者_Go百科 {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!" });
});
I have the exact same problem with a page that contains a contact form (in the body) and a search box (in the header). Clicking the "search" button fires the form validation.
精彩评论