【发布时间】:2014-01-20 15:15:45
【问题描述】:
我有以下一组代码,我试图让它以这样一种方式工作,默认情况下它不会有弹出通知,也没有 X 符号。如果输入无效,应显示输入格式(红色框)和 Red-X。其余的很好,只要有人输入,它就会给出一个绿色的勾号,但在这种情况下,我根本不想要弹出通知。
HTML:
<form action="#" method="GET" id="subscribe" name="subscribe">
<div class="NameForm">
<input class="inputName" type="text" placeholder="Your Name" name="query" aria-describedby="name-format" required >
<span id="name-format" class="helpName">Format: firstname lastname</span>
</input>
</div>
</form>
CSS:
.inputName {
border: 2px solid #306b88;
color: #383838;
font: 14px/14px 'focobold';
height: 40px;
margin: 2px 0;
padding: 0 16px;
text-transform: uppercase;
width:248px;
}
.helpName {
display:none;
font-size:90%;
}
input:focus + .helpName {
display:inline-block;
background-color:#26ae56;
height:38px;
width:240px;
position:absolute;
color:#fff;
left:30px;
top:70px;
text-align:center;
line-height:40px;
}
input:required:invalid, input:focus:invalid {
background-image: url(http://s27.postimg.org/ttonbaj5b/invalid.png);
background-position: 260px center;
background-repeat: no-repeat;
}
input:required:valid {
background-image: url(http://s14.postimg.org/gaechg2e5/valid.png);
background-position: 254px center;
background-repeat: no-repeat;
}
或多或少,这是必需的格式:
【问题讨论】: