onBlur and onFocus event
onBlur and onFocus event
我有一个文本框,它正在使用Phone和onblur的屏蔽插件,我正在删除一个特定的类。然而,在另一个字段的tab键上,它再次变为红色。代码如下:
<input data-val="true" data-val-regex="Alt. Phone is not correct" data-val-regex-pattern="(1-?)?('([2-9]'d{2}')|[2-9]'d{2})-?[2-9]'d{2}-?'d{4}" id="AltPhone" maxlength="14" name="AltPhone" tabindex="6" type="text" value="" class="">
$("#AltPhone").blur(function () {
$(this).removeClass('input-validation-error');
$("label[for='AltPhone']").removeClass('input-validation-error');
});
$("#AltPhone").focus(function () {
$("label[for='AltPhone']").removeClass('input-validation-error');
$(this).removeClass('input-validation-error');
});
blur
函数按预期工作,但focus
未按预期工作。
请检查此代码是否适用,并告诉我。
$("#AltPhone").focusout(function () {
$("label[for='AltPhone']").removeClass('input-validation-error');
$(this).removeClass('input-validation-error');
});
正如您在控制台中看到的,它运行良好。不知道,但可能是因为您的插件。如果可能的话,请张贴一些代码。
$("#AltPhone").blur(function () {
$(this).removeClass('input-validation-error');
$("label[for='AltPhone']").removeClass('input-validation-error');
console.log("blur");
});
$("#AltPhone").focus(function () {
$("label[for='AltPhone']").removeClass('input-validation-error');
$(this).removeClass('input-validation-error');
console.log("focus");
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<input data-val="true" data-val-regex="Alt. Phone is not correct" data-val-regex-pattern="(1-?)?('([2-9]'d{2}')|[2-9]'d{2})-?[2-9]'d{2}-?'d{4}" id="AltPhone" maxlength="14" name="AltPhone" tabindex="6" type="text" value="" class="">
相关文章:
- issue with FB.Event.subscribe
- Angularjs :$routeChangeStart event
- event.prventDefault()持续多久
- 在javascript中传递onmouseenter事件上的onfocus
- <text区域>在我的html中包含event.keycode==13之后,wrap就不起作用了
- KeyDown event for CKeditor
- Javascript events: window.event vs argument reference (funct
- 不使用id的javascript中的onfocus函数
- 动态填充Bootstrap选择选择器:change event dos'不起作用
- <td> focusin event .addclass
- event.preventDefault阻止ajax调用
- google.maps.event.addDomListener(window, 'load', fun
- jQuery event.target is_a_child_of(element)
- event.stopPropagation()在firefox javascript中不起作用
- asp.net text onkeyup event
- 如何从ondragend获取正确的event.pageX
- 面料:“;鼠标:向下”;在event.target中未返回对象
- Javascript onfocus 不支持“event”作为参数
- onBlur and onFocus event
- Html/Javascript - Onfocus event