我的网站上有一个regiester表格。我使用jQuery来检查是否填写了必填字段。从现在开始我有两个必须是字段 - 两个文本输入
这是表格
<form id="regiesterForm" method="post">
<div id="regPseudoDiv">
@Html.TextBoxFor(model => model.Pseudo, new { @id = "txtPseudo", @class = "form-control", @placeholder = "Pseudonim", @style = "margin-bottom: 10px;" })
</div>
<div id="regPhoneDiv">
@Html.TextBoxFor(model => model.PhoneNumber, new { @class = "form-control", @placeholder = "Numer telefonu", @style = "margin-bottom: 10px;" })
</div>
<div id="regEmailDiv">
@Html.TextBoxFor(model => model.Email, new { @type = "email", @id = "txtEmail", @onchange = "checkEmail()", @class = "form-control", @placeholder = "Email", @style = "margin-bottom: 10px;" })
</div>
@Html.TextBoxFor(model => model.Born, new { @type = "datetime", @class = "form-control", @placeholder = "Data urodzenia" })
<div class="radio-inline">
<label style="font-size:10px">@Html.RadioButtonFor(model => model.Gender, "Female")Kobieta</label>
</div>
<div class="radio-inline">
<label style="font-size:10px">@Html.RadioButtonFor(model => model.Gender, "Male") Mezczyzna</label>
</div>
<br>
<div class="text-right">
<input style="margin-top: 20px;" type="submit" id="regiesterButton" class="btn btn-success" value="Zarejestruj" />
</div>
</form>
这是jQuery代码:
$('#regiesterForm').on('submit', function (e) {
if ($('#txtPseudo').val() == 'undefined' || $('#txtPseudo').val() == null) {
e.preventDefault();
$('#regPseudoDiv').addClass('form-group has-warning');
}
if ($('#txtEmail').val() == '') {
e.preventDefault();
$('#regEmailDiv').addClass('form-group has-error');
}
})
关键是在此函数之后bootstrap.min.js中存在错误 调试后,一切似乎都没问题,但是有错误。
错误:
if(!jQuery)throw new Error("Bootstrap requires jQuery");+function(a){"use strict";function b(){var a=document.createElement("bootstrap"),b={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var c in b)if(void 0!==a.style[c])return{end:b[c]}}a.fn.emulateTransitionEnd=function(b).......................... LONG