找到了解决方案,这里是:
HTML:
<script src='http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.0/jquery.validate.min.js'></script>Desired error:
<br />
<input type='text' name='username' class='error' />
<span class='arrow'></span>
<label class='error'>Error</label>
<br />
<br />
<br />
<form action='' method='post' id='myform'>
<input type='text' name='username' required />
<br />
<input type='email' name='email' required />
<br />
<input type='submit' value='submit' />
</form>
CSS:
input {
padding:5px;
}
input.error {
border:1px solid #99182c;
}
span.arrow {
height:17px;
background: url('http://i45.tinypic.com/f9ifz6.png') no-repeat center left;
top:4px;
}
label.error {
border-top:1px solid #99182c;
border-bottom:1px solid #99182c;
border-right:1px solid #99182c;
color:black;
padding:1px 5px 1px 5px;
font-size:small;
}
JavaScript:
$('#myform').validate({
wrapper: 'span',
errorPlacement: function (error, element) {
error.css({'padding-left':'10px','margin-right':'20px','padding-bottom':'2px'});
error.addClass("arrow")
error.insertAfter(element);
}
});