Using ErrorLabelContainer
I can display all the errors on my page in a single div
.
What is the use of errorContainer
?
$("#form_id"). valid(); Checks whether the selected form is valid or whether all selected elements are valid. validate() needs to be called on the form before checking it using this method.
An unobtrusive validation in jQuery is a set of ASP.Net MVC HTML helper extensions.By using jQuery Validation data attributes along with HTML 5 data attributes, you can perform validation to the client-side.
The jQuery Validate is a feature provided by jQuery that makes it easier for the creator to validate the user or visitor's input data while keeping your code free of all the mesh of validation rules from javaScript code.
If you are looking to change colors of text/background of your validation error messages, while there is no built-in method for changing the colors, you can absolutely change this with a little CSS! Just go to the Style tab and scroll to the bottom of the survey preview and click the link to access to HTML/CSS Editor.
Please refer to official documentation where all this is clearly explained.
errorLabelContainer
- All error labels are displayed inside an unordered list with the ID “messageBox”, as specified by the selector passed aserrorContainer
option.
In other words, as an example, the errorLabelContainer
contains the errors as an unordered list. This unordered list goes inside of the errorContainer
.
Example usage:
$('form').validate({
errorContainer: "#messageBox1",
errorLabelContainer: "#messageBox1 ul",
wrapper: "li"
});
Will yield this markup...
<div id="messageBox1"> <!- errorContainer ->
<ul> <!- errorLabelContainer ->
<li>Field is required</li> <!- wrapper ->
<li>Enter a valid email</li> <!- wrapper ->
</ul>
</div>
To play around with how this works, you could create a jsFiddle demo and inspect the DOM to see how the rendered HTML is constructed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With