我在用击倒
hasfocus
用于电话号码验证的事件,当焦点从输入字段中移开时,将弹出验证错误,但只有当我第一次尝试时第二次单击它时,才会发生任何事情
我试着通过在函数中添加一个断点来调试它,所以我认为错误消息已经出现,但是发生了一些事情,错误消息在第一次单击时被删除了
有人能帮忙吗?
widget.isShippingPhoneFocus.subscribe(function (newValue) {
if (!newValue) {
var phoneValid = widget.validatePhone();
if (!phoneValid) {
widget.isPhoneValid(false);
$('#CC-checkoutAddressBook-sphone-error').text(widget.phoneErrorMsg());
$('#CC-checkoutAddressBook-sphone-error').show();
} else {
$('#CC-checkoutAddressBook-sphone-error').hide();
widget.isPhoneValid(true);
}
}
});
<input type="tel" class="form-control" name="sPhone" id="CC-checkoutAddressBook-sphone" data-bind="validatableValue: phoneNumber, widgetLocaleText:{value:'phoneNumberText',attr:'placeholder'}, valueUpdate:'keyup', hasFocus: $parent.isShippingPhoneFocus">