jQuery .validate初始标签文本 [英] jQuery .validate initial label text

查看:104
本文介绍了jQuery .validate初始标签文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道一旦验证该字段可以在标签中显示初始文本,我该怎么做:

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>

将文本Insert Name替换为错误消息,但成功后,它将隐藏标签并擦除初始文本Insert Name.我需要它来再次显示初始文本.

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.

推荐答案

设置类似我显示的消息:

Set the messages like I show:

设置如下:

$("#contact").validate(
    {       
    rules:{
        con_name:{required:true, minlength:3},                      
          }  
    messages: {
          con_name: 'Insert Name'
          }

    });

这篇关于jQuery .validate初始标签文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆