I have a fairly large input form with a number of ASP.NET Validators on it, most are RegexVlidators. Validators work fine on a client side and they prevent a postback(submit) if needed. But now we have to while still validating and displaying errors just like they used to also have to allow postback. I have to replace my RegexValidators with jquery validator plugin, so my question is: can validator plugin used so it flags and displays errors but does not prevent submit/postback? If not, what can be used for that, other then custom solution)? Typical validator in use looks like this:
<asp:RegularExpressionValidator
ID = "ContactEMailValidator"
runat = "server"
ControlToValidate = "ContactEMail"
ErrorMessage = "Contact Email is not a valid e-mail."
ValidationGroup="WorkflowsAndIneligible"
ValidationExpression = "^\s*\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*\s*$"
SetFocusOnError = "true">
</asp:RegularExpressionValidator>
Besides validation it does a number of other things – set focus on offending input control, displays a tabbable error message
I use the Position Absolute inline validation engine to do something similar. It allows you to have full control over the error messages without preventing postback if needed.
For example you can use the
showPromptoption to display an error field over a form field, but still allow ajax posting.More information here – https://github.com/posabsolute/jQuery-Validation-Engine
EDIT: Just a quick example of how you might use this in production –
That example would block the form submission and you could easily build out/display your errors in an
elseblock. If you don’t want to block the form submission you can just ignore the if statement and submit the form regardless and build out your errors fromValidationEngine. You would need to provide a bit more detail for a specific example though.