gpt4 book ai didi

javascript - Jquery表单验证插件中如何修改 "This field is required"的内容?

转载 作者:数据小太阳 更新时间:2023-10-29 04:53:42 27 4
gpt4 key购买 nike

如何将Jquery表单验证插件中的“此字段为必填项”的一般消息更改为“このフイールドナ必须です”?可以使用以下代码更改消息的颜色:

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

</style>

但是如何改变内容呢?

我想更改所有“需要提交此文件”的消息。

我想将所有“必需”消息更改为“このフイールドハ必须です”。

$(".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"
}
}
})

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

我写了

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

}

但它不起作用。

最佳答案

我尝试了接受的答案,但它对我根本不起作用。我在 Google 上进行了更多搜索,发现 this article .

使用这行代码解决了我的问题:

$.validator.messages.required = "Your new required message here!";

关于javascript - Jquery表单验证插件中如何修改 "This field is required"的内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1838695/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com