I'm using the formvalidation.io plugin to perform client-side validation on my pages. I've recently come across a problem where I cannot get the validation to work after a postback within an UpdatePanel (the validated controls are within the UpdatePanel as well).
Start of UP:
<asp:UpdatePanel ID="up1" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ActivityType" EventName="SelectedIndexChanged" />
<asp:AsyncPostBackTrigger ControlID="ActivitySubType" EventName="SelectedIndexChanged" />
</Triggers> .... </asp:UpdatePanel>
The validation works as intended until a postback occurs. Each time ActivityType or ActivitySubType perform a postback, all validation disappears.
Javascript / jQuery:
$(function () {
docReady();
});
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(function () { docReady(); });
function docReady() {
$("#aspnetForm").formValidation({
message: 'This value is not valid',
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
ctl00$maincontent$ActivityDate:
{
validators: {
notEmpty: {
message: 'Date / Time is required'
}
}
},
...
}
}); } });
I've tried doing the validation declaratively as well with the same result. I've also tried re-initializing the validation using the console after postback with no luck.
I'm a bit frustrated b/c I've tried everything I know to do. Thanks!