Twitter bootstrap 即使没有不正确的字段,提交按钮在引导验证程序中也不起作用

Twitter bootstrap 即使没有不正确的字段,提交按钮在引导验证程序中也不起作用,twitter-bootstrap,submit-button,jqbootstrapvalidation,Twitter Bootstrap,Submit Button,Jqbootstrapvalidation,在我的HTML和JavaScript代码中,除了submit按钮之外,所有的东西都工作得很好,如果任何表单字段中没有错误,submit按钮应该提交页面,但是它没有提交 <div class="container"> <div class="panel panel-default"> <div class="panel-heading">Registration</div> &l

在我的HTML和JavaScript代码中,除了submit按钮之外,所有的东西都工作得很好,如果任何表单字段中没有错误,submit按钮应该提交页面,但是它没有提交

    <div class="container">
        <div class="panel panel-default">
            <div class="panel-heading">Registration</div>
            <div class="panel-body">
                <form id="registration-form" method="post" class="form-horizontal">

                    <div class="form-group">
                        <label class="col-md-2 control-label" for="fName">First Name</label>
                        <div class="col-md-4">
                            <input type="text" class="form-control" id="fName" name="fName" placeholder="First Name"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label" for="lName">Last Name</label>
                        <div class="col-md-4">
                            <input type="text" class="form-control" id="lName" name="lName" placeholder="Last Name"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label" for="email">E-mail ID</label>
                        <div class="col-md-4">
                            <input type="text" class="form-control" id="email" name="email" placeholder="Your E-mail address"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label"  for="password">Password</label>
                        <div class="col-md-4">
                            <input type="password" class="form-control"  id="password" name="password" placeholder="Password"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label" for="confirmPasword">Confirm Password</label>
                        <div class="col-md-4">
                            <input type="password" class="form-control" id="confirmPasword" name="confirmPasword" placeholder="Confirm Password"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-md-6 col-xs-offset-2 ">
                            <button type="submit" class="btn btn-success" name="submit" >Submit</button>
                        </div>
                    </div>

                </form>

            </div>
        </div>
    </div>

    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script     src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js">     </script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap.min.js"></script>
    <script src="js/bootstrapValidator.min.js" type="text/javascript">     </script>
</body>

<script type="text/javascript">
    $(document).ready(function(){
        $('#alwaysEnableButtonForm')
        var validator = $("#registration-form").bootstrapValidator({
            feedbackIcons:{
                valid:"glyphicon glyphicon-ok",
                invalid:"glyphicon glyphicon-remove",
                validating:"glyphicon glyphicon-refresh"
            },
            fields:{
                fName:{
                    message:"First Name is required",
                    validators:{
                        notEmpty:{
                            message:"Please provide the First Name"
                        },
                        stringLength:{
                            max : 25,
                            message: "The first Name should not be more than 25 characters long"    
                        }
                    }
                },
                lName:{
                    message:"Last Name is required",
                    validators:{
                        notEmpty:{
                            message:"Please provide the Last Name"
                        },
                        stringLength:{
                            max : 25,
                            message: "The Last Name should not be more than 25 characters long" 
                        }
                    }
                },
                email:{
                    message:"E-mail address is required",
                    validators:{
                        notEmpty:{
                            message:"Please an E-mail address"
                        },
                        stringLength:{
                            min:6,
                            max:45,
                            message: "E-mail address must be between 6 and 45 characters long"
                        },
                        emailAddress:{
                            message:"E-mail address is invalid"
                        }
                    }
                },
                password:{
                    validators:{
                        notEmpty:{
                            message:"Password is required"
                        },
                        stringLength:{
                            min:8,
                            message:"Password must be 8 digits long atleast"
                        },
                        different:{
                            field:"email",
                            message:"E-mail address and password can not match"
                        }

                    }
                },
                confirmPasword:{
                    validators:{
                        notEmpty:{
                            message:"This field is required"
                        },
                        identical:{
                            field:"password",
                            message:"This should must match the first password"
                        }
                    }
                }
            }
        })
        .on('success.fields.fv', function(e, data) {
            if (data.fv.getInvalidFields().length > 0) {    // There is invalid  field
                data.fv.disableSubmitButtons(true);
            }
        });

    });
</script>

登记处
名字
姓
电子邮件ID
密码
确认密码
提交
$(文档).ready(函数(){
$(“#alwaysEnableButtonForm”)
var验证程序=$(“#注册表”).bootstrapValidator({
反馈图标:{
有效:“glyphicon glyphicon ok”,
无效:“glyphicon glyphicon删除”,
正在验证:“glyphicon glyphicon刷新”
},
字段:{
fName:{
消息:“需要名字”,
验证器:{
注意:{
信息:“请提供您的名字”
},
弦长:{
最高:25,
消息:“名字长度不应超过25个字符”
}
}
},
名称:{
消息:“姓氏是必需的”,
验证器:{
注意:{
信息:“请提供姓氏”
},
弦长:{
最高:25,
消息:“姓氏长度不应超过25个字符”
}
}
},
电邮:{
消息:“需要电子邮件地址”,
验证器:{
注意:{
信息:“请输入电子邮件地址”
},
弦长:{
民:6,,
最高:45,
消息:“电子邮件地址长度必须介于6到45个字符之间”
},
电子邮件地址:{
消息:“电子邮件地址无效”
}
}
},
密码:{
验证器:{
注意:{
消息:“需要密码”
},
弦长:{
民:8,,
消息:“密码长度至少必须为8位”
},
不同的:{
字段:“电子邮件”,
消息:“电子邮件地址和密码不匹配”
}
}
},
确认密码:{
验证器:{
注意:{
消息:“此字段为必填字段”
},
相同:{
字段:“密码”,
消息:“此密码必须与第一个密码匹配”
}
}
}
}
})
.on('success.fields.fv',函数(e,数据){
如果(data.fv.getInvalidFields().length>0){//则存在无效字段
data.fv.disableSubmitButtons(真);
}
});
});

您需要为表单设置一个操作。例如

    <form action="somefile.php" method="POST" >
            <!--Your Form-->
    </form>


我正在使用手机,因此无法测试您的代码,但请尝试更改为,并将button类添加到输入标记。欢迎使用Stack Overflow!我已经修改了一些拼写,并使代码中的缩进保持一致,这样每个人都更容易阅读。JavaScript控制台中是否有对某人有用的内容(错误等)?演示这个问题也会很有帮助。