BootstrapValidator dosen';你不能使用xpages吗?

BootstrapValidator dosen';你不能使用xpages吗?,xpages,bootstrapvalidator,Xpages,Bootstrapvalidator,我是bootstrap的初学者,我曾试图用BootstrapValidator构建一个Xpage来验证inputText,但它不起作用,在代码源代码下面,我们能帮我找到解决方案吗 <?xml version="1.0" encoding="UTF-8"?> <xp:view xmlns:xp="http://www.ibm.com/xsp/core" xmlns:xc="http://www.ibm.com/xsp/custom"> <xp:this.

我是bootstrap的初学者,我曾试图用BootstrapValidator构建一个Xpage来验证inputText,但它不起作用,在代码源代码下面,我们能帮我找到解决方案吗

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core"
    xmlns:xc="http://www.ibm.com/xsp/custom">
   <xp:this.resources>
   <xp:styleSheet href="/bootstrapValidator/css/bootstrap.css"></xp:styleSheet>
   <xp:styleSheet href="/bootstrapValidator/css/bootstrapValidator.css"></xp:styleSheet>
   <xp:script src="/JQueryXSnippet.js" clientSide="true"></xp:script>
   <xp:script src="/bootstrapValidator/js/bootstrap.min.js" clientSide="true">  </xp:script>
   <xp:script src="/bootstrapValidator/js/bootstrapValidator.js" clientSide="true"></xp:script>
    </xp:this.resources>
                <div class="col-md-5">
                <xp:inputText id="username" title=" username"></xp:inputText>
</div>

<xp:scriptBlock id="scriptBlock1">
<xp:this.value><![CDATA[$(document).ready(
function() {
        $("#{id:username}" ).bootstrapValidator({
        message: 'This value is not valid',
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        fields: {
            username: {
                message: 'The username is not valid',
                validators: {
                    notEmpty: {
                        message: 'The username is required and can\'t be empty'
                    },
                    stringLength: {
                        min: 6,
                        max: 30,
                        message: 'The username must be more than 6 and less than 30 characters long'
                    },
                    regexp: {
                        regexp: /^[a-zA-Z0-9_\.]+$/,
                        message: 'The username can only consist of alphabetical, number, dot and underscore'
                    }
                }
            } } });
              ]]></xp:this.value>
</xp:scriptBlock>

          </xp:view>

使用而不是本机jQuery$选择器

还可以尝试使用
XSP.addOnLoad()
而不是
(document.ready()

此外,名为“username”的XPages xp:inputText字段在浏览器中有一个名为“view:_id1:_id2:_id8:username”的id。因此,它并不像bootstrapValidator的字段定义中所述的那样称为“用户名”。因此,bootstrapValidator无法找到该字段。尝试将其添加到脚本块,而不是
“用户名:{”


请检查javascript控制台是否有错误?谢谢Oliver Busse,但我在检查java脚本控制台时没有任何错误!谢谢Per Henrik Lausten,我更改了函数,并使用x$jQuery选择器代替jQuery:OK,下一个问题很可能是对“用户名”的引用:在bootstrapValidator配置中。您需要添加字段的正确客户端名称。我遵循本教程,我不明白客户端名称是什么意思?您的XPages xp:inputText字段用户名在浏览器中有一个id,称为“view:_id1:_id2:_id8:username”。因此它不是“username”正如bootstrapValidator的字段定义中所述。因此bootstrapValidator无法找到字段。我试图将用户名更改为“#{id:username}:”,然后我添加了表单的名称,因为我在教程“twitterbootstrap.org/bootstrap form validation”中重复代码js时bootstrapValidator函数应用于带有html的表单!我从客户端用id修改了表单的名称,但仍然存在相同的问题没有验证!!下面的代码源代码有更改!
#{id:username}: {