How to conditionally disable client side validation in xVal?
I am using xVal in a ASP.NET MVC project. One of the forms has two buttons and i want to disable the client side validation when one of the buttons is clicked. Is there a way to conditionally disable cli开发者_运维百科ent side validation in xVal?
Instead of disabling client side validation... we can have rules execution only when we need it with the help of JQuery validate method.
For Example: On button click event upon which validation rules to be fired... apply jquery form validation...
$("#ButtonID").click(function() {
var valid = $("#FormID"); // Form ID to be entered
//var validDate = validateDate(f);
var validForm = valid.validate().form();
// Set delay for 500ms so that all ajax validations would complete.
setTimeout(function() { $("#FormID").validate().form(); }, 500); // Form ID to be entered
validForm = valid.validate().form();
if (validForm) {
// Post form data to server
}
});
Not sure about xVal in particular, but with an Asp.Net form you can do the following-
<asp:Button id="IgnoreClientValidation" runat="server" Text="Ignore Client" EnableClientScript="False" />
精彩评论