Jquery 验证消息更改(自定义消息集)
Jquery validation msg change (Custom msg set)
我想设置 jquery 验证的自定义消息。我的表单代码:它总是给出味精:"You have not answered all required fields"。但是我想改变。
<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>
<script src="//code.jquery.com/jquery-1.9.1.js"></script>
<script src="//ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js"></script>
<form id="addproductform" method="post" action="" role="form">
<div class="col-md-6">
<div class="form-group">
<label>Name </label>
<input name="name" class="form-control" placeholder="Enter name" >
<input type="submit">
</div>
</form>
<!-- jQuery Form Validation code -->
<script>
// When the browser is ready...
$(function() {
// Setup form validation on the #register-form element
$("#addproductform").validate({
// Specify the validation rules
rules: {
name: "required",
},
// Specify the validation error messages
messages: {
name: "Please enter your name",
},
submitHandler: function(form) {
form.submit();
}
});
});
</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>
我想设置 jquery 验证的自定义消息。我的表单代码:它总是给出味精:"You have not answered all required fields"。但是我想改变。
<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>
<script src="//code.jquery.com/jquery-1.9.1.js"></script>
<script src="//ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js"></script>
<form id="addproductform" method="post" action="" role="form">
<div class="col-md-6">
<div class="form-group">
<label>Name </label>
<input name="name" class="form-control" placeholder="Enter name" >
<input type="submit">
</div>
</form>
<!-- jQuery Form Validation code -->
<script>
// When the browser is ready...
$(function() {
// Setup form validation on the #register-form element
$("#addproductform").validate({
// Specify the validation rules
rules: {
name: "required",
},
// Specify the validation error messages
messages: {
name: "Please enter your name",
},
submitHandler: function(form) {
form.submit();
}
});
});
</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>