Introduction of "Clearing client side validation error messages in MVC"
In this article i am going to explain, how to clear the client side validation messages in MVC. This post will be useful if you are using dataannotation validations in MVC. In forum we were discussing about one scenario -
When you have two buttons in a page "Save" and "Cancel" , on click of "Cancel" button say you are doing AJAX call then you might have observed that client side messages still shown in the page. You might have read my articles - Client side validation using jquery in asp.net mvc and Jquery validation plugin remove rules where i have explained alternate approach for model validations.
Approach for "Clearing client side validation error messages in MVC"
Below is the code for clearing client side validation messages in MVC -
Suppose you want to remove validation messages from your partialview/pop up then you can use it like this -
Hope it helps to solve your issue as well. Thanks to my colleague shwetha for discussing this issue.
Please comment below.
In this article i am going to explain, how to clear the client side validation messages in MVC. This post will be useful if you are using dataannotation validations in MVC. In forum we were discussing about one scenario -
When you have two buttons in a page "Save" and "Cancel" , on click of "Cancel" button say you are doing AJAX call then you might have observed that client side messages still shown in the page. You might have read my articles - Client side validation using jquery in asp.net mvc and Jquery validation plugin remove rules where i have explained alternate approach for model validations.
Approach for "Clearing client side validation error messages in MVC"
Below is the code for clearing client side validation messages in MVC -
function clearValidationMessages() { $('.input-validation-error').addClass('input-validation-valid'); $('.input-validation-error').removeClass('input-validation-error'); //removing validation message from tag created dynamically $('.field-validation-error').addClass('field-validation-valid'); $('.field-validation-error').removeClass('field-validation-error'); $('.validation-summary-errors').addClass('validation-summary-valid'); $('.validation-summary-errors').removeClass('validation-summary-errors'); }
Suppose you want to remove validation messages from your partialview/pop up then you can use it like this -
function clearValidationMessages() { $('#yourpopupID .input-validation-error').addClass('input-validation-valid'); $('#yourpopupID .input-validation-error').removeClass('input-validation-error'); //removing validation message from tag created dynamically $('#yourpopupID .field-validation-error').addClass('field-validation-valid'); $('#yourpopupID .field-validation-error').removeClass('field-validation-error'); $('#yourpopupID .validation-summary-errors').addClass('validation-summary-valid'); $('#yourpopupID .validation-summary-errors').removeClass('validation-summary-errors'); }
Hope it helps to solve your issue as well. Thanks to my colleague shwetha for discussing this issue.
Please comment below.
No comments:
Post a Comment
Comments Section