问题
and this also not worked for me an error occurd when I tried this:
error.insertBefore(element)
error.css('float','left')
or:
error.attr('style','float:left')
only I can add these properties like this:
$(error).someproperty
This is my code as I can't copy paste because I work on TFS and copy/paste is not allowed. Problem is that with this code I can not float left error message. I want that error should appear on left and below the textbox. One thing more, I was just testing and I put float =right in picture above so forget about it. float:left is also not working. I have checked it.
回答1:
As per the documentation, rules('add', rules) is only a method for adding your rules and their messages, nothing else. You've improperly placed errorElement:, wrapper:, and errorPlacement: within your rules('add', rules) method.
errorElement:, wrapper:, and errorPlacement: are not rules. These are called options and therefore would only be placed within .validate(options).
$(document).ready(function(){
$('#myform').validate({
errorElement: 'div',
wrapper: 'div',
errorPlacement: function(error, element) {
error.insertAfter(element); // default function
}
});
});
Otherwise, I don't know what you're asking and you should put your actual code within the OP, so we don't have to re-type it in order to answer.
来源:https://stackoverflow.com/questions/14625228/jquery-validation-position-error-label