我有这个字段,我想检查它是否有效,如果不是这样,我想显示一个弹出框。

$(document).ready(function(){

$('input[name=email]').keyup(email_check);
});

function email_check(){

    $('input[name=email]').parent().removeClass("has-error has-feedback").removeClass("has-success has-feedback");
    $('span.glyphicon').remove();
    var email = $('input[name=email]').val()
if( !isValidEmailAddress( email ) ) {

$("input[name=email]").popover({trigger: 'focus', content: "Error!", placement : 'bottom'});
$('input[name=email]').parent().addClass( "has-error has-feedback" ).append("<span class='glyphicon glyphicon-remove form-control-feedback'></span>");
return false;
    }else{
        $("input[name=email]").popover({trigger: 'focus', content: "Valid!", placement : 'bottom'});
        $('input[name=email]').parent().addClass( "has-success has-feedback" ).append("<span class='glyphicon glyphicon-ok form-control-feedback'></span>");

    return true;
    }
}

这里的问题是,直到我离开现场并再次专注于它时,popver 才会显示!希望你明白我的意思!我该如何解决?

非常感激!

最佳答案

http://bootply.com/124932

需要将popover trigger改成manual,然后使用show方法来显示popover...

$("input[name=email]").popover({trigger: 'manual', content: "Error!", placement : 'bottom'});
$("input[name=email]").popover('show');

关于javascript - 完成输入后显示引导弹出窗口,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22659005/

10-12 12:49
查看更多