Response title
This is preview!
$("#forma").validate({
errorClass: "red"
});
$("#input").each(function(index, elem) {
var rules = {
required:true
};
$(elem).rules("add", rules);
});
<label id="lastname-error" class="red" for="lastname">This field is required.</label>
span
element inside of those labels, at the beginning (prependTo) with
the background-image and other CSS properties, so it will look like this:<label id="lastname-error" class="red" for="lastname"><span class="myspan"></span><This field is required.</label>
$("#forma").validate({
errorClass: "red",
errorPlacement: function(error, element) {
var html = '<span class="myspan"></span>' + $(error).text();
$(error).html(html).insertAfter(element);
}
});
This probably means that errorPlacement doesn't 'fire' everytime when errors occur...
So, I tried with highlight:
highlight: function(element, errorClass) { $("label."+errorClass).prepend('<span class="
myspan
"></span>') }
And it works, but it adds more then 1 span within the error label.
Do you know how can I solve this problem?
The reason why I want to instert span element with some class within error label is because I want to put background-image to those spans (right arrow picture that will point to input)...
© 2013 jQuery Foundation
Sponsored by and others.