I'm styling my error messages of the Jquery Validation plugin and I'm running into some difficulties.
I've already edited the code of the plugin to change language of the messages. I know this can be done with javascript, but it seems better to do it 'hardcoded'. This isn't seen in the live example though.
Here's the live example.
I need to insert a <span></span>
before the error message somehow, but I can't figure out how to. Any ideas?
To be clear: instead of the plugin showing an elemenent with a class 'error', it should display like so:
<span class='pointer'></span><label class='error'>This is the error</label>
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.
This jQuery plugin makes simple clientside form validation easy, whilst still offering plenty of customization options. It makes a good choice if you're building something new from scratch, but also when you're trying to integrate something into an existing application with lots of existing markup.
For jQuery form validation to work, we set "HtmlHelper. UnobtrusiveJavaScriptEnabled = false;" property false in the register form instead of "web. config" file; this means if we set the value false for above property in "web. config" file, then we will disable client side validation across application.
The plugin adds a validationPlugin function to jQuery. fn , so simply check whether it exists or not; if (typeof jQuery. fn.
i think your best choice will be wrapper of error element and some CSS styling:
$('#myform').validate({
errorPlacement: function(label, element) {
label.addClass('arrow');
label.insertAfter(element);
},
wrapper: 'span'
});
which gives you errors like this:
<span class='arrow'>
<label class='error'>Error</label>
</span>
and with some CSS you get it done.
span.arrow {
margin-left: 6px;
height:17px;
background: url('http://i45.tinypic.com/f9ifz6.png') no-repeat left center;
}
label.error {
height:17px;
border-top:1px solid #99182c;
border-right:1px solid #99182c;
border-bottom:1px solid #99182c;
margin-left:9px;
padding:1px 5px 0px 5px;
font-size:small;
}
live demo
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