如何更改“此字段是必需的”内容在Jquery表单验证插件? [英] How to change the content of "This field is required" in Jquery form validation plugin?

查看:99
本文介绍了如何更改“此字段是必需的”内容在Jquery表单验证插件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Jquery表单验证插件中将此字段是必需的的常规消息更改为このフィールドは必须です?可以使用以下代码更改邮件的颜色:

How can I change the general message of "This field is required" in Jquery form validation plugin to "このフィールドは必須です"? The color of the message can be changed by using the following code:

<style type="text/css">
label.error {color: red;}

</style>

但如何更改内容?

我想更改所有此字段是必填的消息。

I want to change all "This filed is required" messages.

我想将所有必填消息更改为このフィールドは必须です。

I want to change all "required" messages to "このフィールドは必須です".

$(".selector").validate({
   rules: {
     name: "required",
     email: {
       required: true,
       email: true
     }
   },
   messages: {
     name: "Please specify your name",
     email: {
       required: "We need your email address to contact you",
       email: "Your email address must be in the format of name@domain.com"
     }
   }
})

仅更改特定规则的特定消息和特定元素。

only changes specific message for specific rule and specific element.

我写了

 messages: { 
        required:"このフィールドは必須です"

        }

但是它没有rk。

推荐答案

消息对象有几个有趣的属性需要调整:

The messages object has several interesting attributes to adjust:

messages: {
    required: "This field is required.",
    remote: "Please fix this field.",
    email: "Please enter a valid email address.",
    url: "Please enter a valid URL.",
    ...
}

参见来源

这些可以通过 setDefaults()方法:

$.validator.setDefaults({
    messages: {
        required: "このフィールドは必須です"
    }
});

这篇关于如何更改“此字段是必需的”内容在Jquery表单验证插件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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