gpt4 book ai didi

javascript - jquery验证消息变化(自定义消息集)

转载 作者:行者123 更新时间:2023-11-30 11:59:44 24 4
gpt4 key购买 nike

我想设置 set Custom msg of jquery validation。我的表单代码:它总是给消息:“你没有回答所有必填字段”。但我想改变。

<form id="addproductform" method="post" action="" role="form">
<div class="col-md-6">
<div class="form-group">
<label>Name </label>
<input data-validation="required" data-msg="Please enter your first name" class="form-control" placeholder="Enter name">
</div>
</form>

Jquery:-

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-form-validator/2.2.8/jquery.form-validator.min.js"></script>
<script>
$.validate({
decimalSeparator: ','
});
</script>

最佳答案

请使用 data-validation-error-msg="Please enter your first name" 而不是 data-msg="Please..." 如下:

$.validate({
decimalSeparator: ','
});
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-form-validator/2.2.8/jquery.form-validator.min.js"></script>
<form id="addproductform" method="post" action="" role="form">
<div class="col-md-6">
<div class="form-group">
<label>Name </label>
<input data-validation="required" data-validation-error-msg="Please enter your first name" class="form-control" placeholder="Enter name">
</div>
<input type="submit" value="Submit" />
</form>

关于javascript - jquery验证消息变化(自定义消息集),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36951635/

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