location of JQuery error validation
I kn开发者_C百科ow that we can use errorPlacement to set where we want the error message will be. I have created a css that would help this. Here is the code:
label.error {
display: inline;
clear: both;
color:#200;
margin:5px 0;
}
what is it that I must do to display the error next to the <input>
using the error label
that I have created
Check out the errorPlacement: option here: http://docs.jquery.com/Plugins/Validation/validate
errorPlacement: function(error, element) {
if (element.attr("name") == "someName"){
error.insertBefore("input[name=someName]:first");
}
else{
error.insertAfter(element);
}
},
Another example from the api I linked above
$("#myform").validate({
errorPlacement: function(error, element) {
error.appendTo( element.parent("td").next("td") );
},
debug:true
})
edit
It looks like in the example, they are just styling the .warning
label to be displayed inline.
#stepForm label.warning {
text-align: left;
width: auto;
padding: 0;
margin: 0 0 0 10px;
float: none;
clear: none;
display: inline;
color: #CC3366;
font-size: 10px;
border: none;
border-top: 1px dotted #CC3366;
}
精彩评论