我正在验证表单输入,例如,单击某个button.If时说First Name为空
.ValidateError
{
border: 3px solid #ff9600;
background: #ffebe9;
padding: 4px 4px 5px 4px;
color: #404040;
}将焦点放在文本框上,我尝试使用document.ready上的以下脚本从输入框中删除此类
$('#divPersonalInfo input').focusin(function () {
$(this).removeClass().addClass('input w220');
});
});这是html代码
<div id="divPersonalInfo" class="PersonalInfo">
<h2 id="hPersonal">
Personal Information
</h2>
<div class="FormColumn FloatLeft">
<label>
first name*
</label>
<br />
<input maxlength="100" id="txtFirstName" placeholder="First Name" class="input w220 "/>
</div>
<div class="FormColumn FloatLeft">
<label>
last name*
</label>
<br />
<input maxlength="100" id="txtLastName" placeholder="Last Name" class="input w220"/>
</div>
<div class="FormColumn FloatLeft">
<label>
email*
</label>
<br />
<input maxlength="100" id="txtPersonalEmailId" placeholder="will be seen when sending your web profile/app to your colleagues" class="input w220"/>
</div>
</div>但是这个类并没有被移除
发布于 2013-08-13 18:43:52
如果只想删除"ValidateError“,则应该编写一个类名。
$(this).removeClass("ValidateError");顺便说一句。使用jquery,您可以像这样使用焦点
$(selector).focus(function) https://stackoverflow.com/questions/18206886
复制相似问题