问题
hi i was wondering how can i make for once the field is validate to show initial text in label:
jQuery:
$("#contact").validate({
rules: {
con_name: {
required:true,
minlength:3
},
}
});
HTML:
<form id="contact" method="post" action="">
<input type="text" name="con_name" id="con_name" />
<label for="con_name" generated="true" class="error">Insert Name</label>
</form>
The text Insert Name is replaced with the error message but upon success it hides the label and erases the initial text Insert Name. I need it to show again the initial text.
回答1:
Set the messages like I show:
Set like this:
$("#contact").validate(
{
rules:{
con_name:{required:true, minlength:3},
}
messages: {
con_name: 'Insert Name'
}
});
来源:https://stackoverflow.com/questions/12203208/jquery-validate-initial-label-text