0
我正在使用'bootstrapvalidator'來驗證我的表單(引導程序的註冊和登錄模式)。當我把任何模式中的正確數據說登錄然後登錄按鈕(提交登錄表格)被禁用,因爲數據不正確。但是當我從密碼字段清除數字,然後再次輸入它並嘗試提交它提交表單的表單。引導程序中的bootstrapValidator中的奇怪錯誤使用引導程序
我不知道爲什麼會發生這種情況,是什麼導致了錯誤。
我正在使用cdns從https://cdnjs.com所有cdn總共8個cdn鏈接。
我的表單代碼(模態登錄)
<div id="login" class="modal fade " role="dialog">
<div class="modal-dialog login-modal">
<div class="modal-content">
<form action="logindone.jsp" method="post" class="form-horizontal" role="form">
<div class="modal-header">
<a class="close cross" data-dismiss="modal">x</a>
<h3>Login</h3>
</div>
<div class="modal-body">
<div class="form-group">
<label for="email-name" class="col-md-2 control-label glyphicon glyphicon-user"></label>
<div class="col-md-10">
<input type="email" class="form-control" id="email-name" name="email">
</div>
</div>
<div class="form-group">
<label for="email-pass" class="col-md-2 control-label glyphicon glyphicon-lock"></label>
<div class="col-md-10">
<input type="password" class="form-control" id="email-pass" name="password">
</div>
</div>
</div>
<div class="modal-footer modal-footer-hidden-border">
<a href="#" class="btn btn-link" data-dismiss="modal">Forgot password ?</a>
<button type="submit" value="submit" class="btn btn-danger btn-circle-lg glyphicon">Log in</button>
</div>
</form>
</div>
</div>
</div>
我引導驗證碼
<script>
$(document).ready(function() {
var validator = $('#login').bootstrapValidator({
fields: {
email: {
message: "Email is required",
validators: {
notEmpty: {
message: "Please provide an email address"
},
stringLength: {
min: 6,
max: 35,
message: "Email must be between 6 and 35 characters long"
},
emailAddress: {
message: "Email address must be valid"
},
regexp: {
regexp: /^(([^<>()\[\]\\.,;:\[email protected]"]+(\.[^<>()\[\]\\.,;:\[email protected]"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
message: 'Not a valid email address'
}
}
}, //.email
password: {
validators: {
notEmpty: {
message: "Password is required"
},
stringLength: {
min: 8,
message: "Password must be 8 characters long"
},
different: {
field: "email",
message: "Email and Password must be different"
}
}
}
}
});
});
</script>
謝謝主席先生。 –
如果可能,你可以告訴我如何在其中引入jquery ajax,以便成功的驗證用戶可以使用ajax登錄,就像他/她的用戶名和密碼將由ajax從數據庫中提取一樣。 –
我完全不瞭解JSP,但在bootstrapvalidator中,經過成功驗證後,您可以處理'submithandler'內的任何內容,下面是通過模式中的bootstrapvalidtor進行表單驗證的示例以及使用submithandler http://bv.doc.javake.cn/examples /#modal – Shehary