gpt4 book ai didi

javascript - 将 Bootstrap 验证消息颜色更改为红色

转载 作者:行者123 更新时间:2023-11-30 09:28:17 25 4
gpt4 key购买 nike

如果输入无效的电子邮件,我有一个表单会发布错误消息。我想将错误消息文本更改为红色。我该怎么做?

$('#subscribe-form').bootstrapValidator({
live: 'disabled',
fields: {
email: {
validators: {
emailAddress: {
message: 'Please enter a valid email address'
}
}
},
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form role="form" id="subscribe-form">
<div class="form-group">
<input type="email" class="form-control custom-email" name="email" id="email" placeholder="Email Address">
</div>
<button type="submit" class="btn btn-large custom-button">Sign up !</button>
</form>

最佳答案

只需在您的代码中添加以下 css

.has-error .help-block {
color: red;
}

$('#subscribe-form').bootstrapValidator({
live: 'disabled',
fields: {
email: {
validators: {
emailAddress: {
message: 'Please enter a valid email address'
}
}
},
}
});
.has-error .help-block {
color: red;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-validator/0.5.3/js/bootstrapValidator.min.js"></script>
<form role="form" id="subscribe-form">
<div class="form-group">
<input type="email" class="form-control custom-email" name="email" id="email" placeholder="Email Address">
</div>
<button type="submit" class="btn btn-large custom-button">Sign up !</button>
</form>

关于javascript - 将 Bootstrap 验证消息颜色更改为红色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48011834/

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