I have been trying to figure this out, I know validation can be fired within a form as long as the button is of type submit. But I have a few other tabs on the view and when I use submit, it causes a posback and goes back to the first tab. I don't want that to happen so I put my validation in a function and changed the button type to a button and removed the form tag and tried calling the validation function on the button click event and its not firing. Is this possible to do without using a form tag?
My code is this...
$(document).ready(function () {
$("#btnUpdateModerator").click(function () {
ValidateIt();
});
ValidateIt();
});
function ValidateIt() {
var validator = $("#Users").bootstrapValidator({
feedbackIcons: {
valid: "glyphicon glyphicon-ok",
invalid: "glyphicon glyphicon-remove",
validating: "glyphicon glyphicon-refresh"
},
fields: {
DealerUsername: {
message: "Username is required",
validators: {
notEmpty: {
message: "Please Provide Username"
}
}
},
email: {
message: "Email address is required",
validators: {
notEmpty: {
message: "Please provide Email address"
},
emailAddress: {
message: "Email address was invalid"
}
}
},
password: {
validators: {
notEmpty: {
message: "Password is required"
},
stringLength: {
min: 6,
message: "Password must be at least 6 characters long"
},
different: {
field: "email",
message: "Email and Password cannot match"
}
}
},
confirmPassword: {
validators: {
notEmpty: {
message: "Confirm Password is required"
},
identical: {
field: "password",
message: "Password and Confirmation Password must match"
}
}
},
department: {
validators: {
notEmpty: {
message: "Department is Required"
}
}
}
}
});
}