简体   繁体   English

防止表单验证CSS .error突出显示文本框

[英]Prevent Form Validation CSS .error from highlighting textbox

I am using the form validation JQuery plugin, and I have everything working quite well, except for one particular thing. 我使用的是表单验证JQuery插件,除了一件特殊的事情,我的所有工作都很好。

I am using the error class in CSS to stylize how the error text looks like so: 我在CSS中使用错误类来样式化错误文本的外观,如下所示:

.error {
    font-family: Verdana, Arial, sans-serif;
    font-size: 0.7em;
    color: #2d0004;
    background-color: #ff0;
}

However, whenever I get an error (a required field not being filled), the inputbox is also affected by the CSS styling shown above. 但是,每当出现错误(未填写必填字段)时,inputbox也会受到上面显示的CSS样式的影响。 How can I prevent the CSS styling shown above from affecting the input field associated with the error, and only apply the style to the error text? 如何防止上面显示的CSS样式影响与错误相关的输入字段,而仅将样式应用于错误文本?

Thanks in advance. 提前致谢。

Try this CSS: 试试这个CSS:

.error:not(input) {
    font-family: Verdana, Arial, sans-serif;
    font-size: 0.7em;
    color: #2d0004;
    background-color: #ff0;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM