我試圖把我的下拉列表中的jQuery驗證在完整的日曆添加事件,但我不知道爲什麼任何解決方案不工作..誰能幫忙嗎?jquery驗證不工作在我的mvc4項目
HTML代碼:
<div id="add_task_dialog_box" class="hide">
<form id="form_data" method="post" class="form-horizontal" style="display: none;">
<fieldset class="form-group">
<div class="row class1 " style="padding: 10px;">
<span><span class="col-lg-3 col-md-3 col-sm-3 col-xs-12">
<label for="dd1" style="font-weight: bold; font-size: 13px; font-type: Arial; font-family: Arial Unicode MS">
Project Name</label></span> <span class="col-lg-3 col-md-3 col-sm-3">@Html.DropDownListFor(model => model.Task_runsModel.Project_Id, db.getProjects(a), "---Select---", new { style = "width:200px;", id = "myproject", name = "Project", @class = "required" })</span>
@Html.ValidationMessageFor(model => model.Task_runsModel.Project_Id)
</span>
</div>
<div class="row class1 " style="padding: 10px;">
<span><span class="col-lg-3 col-md-3 col-sm-3 col-xs-12">
<label style="font-weight: bold; font-size: 13px; font-type: Arial; font-family: Arial Unicode MS">
Select Task</label></span> <span class="col-lg-3 col-md-3 col-sm-3">@Html.DropDownListFor(model => model.Task_runsModel.Task_Id, db.getTasks(a, c), "--Select--", new { style = "width:200px;", id = "mytask", name = "Task", @class = "required" })</span>
@Html.ValidationMessageFor(model => model.Task_runsModel.Task_Id)
</span>
</div>
<div class="row class1" style="padding: 10px;">
<span><span class="col-lg-3 col-md-3 col-sm-3 col-xs-12">
<label style="font-weight: bold; font-size: 13px; font-type: Arial; font-family: Arial Unicode MS">
Task status
</label>
</span><span class="col-lg-3 col-md-3 col-sm-9 col-xs-12 ">@Html.DropDownListFor(model => model.Task_runsModel.status, db.getStatus(), "---Select---", new { style = "width:200px", id = "taskstatus", name = "Status", @class = "required" })
</span>
@Html.ValidationMessageFor(model => model.Task_runsModel.status)
</span>
</div>
<div class="col-lg-12 col-md-3 col-sm-3 col-xs-12">
<div id="chatarea" class="dropdown-toggle" style="float: left; padding-left: 20px;
overflow-y: auto; overflow-x: auto;">
</div>
<b style="float: right; padding-right: 20px;" class="glyphicon glyphicon-chevron-down"
id="DisplayComment"></b>
</div>
@* <div id="commentdiv" class="dropdown-toggle" style=" padding-left: 20px; overflow-y: auto; overflow-x: auto;width:100%">
<ul id="current_comments" type="none" style="font-weight:bold;">
</ul>
</div>*@
<div id="textareadiv" style="padding-top:3px;">
<span class="col-lg-3 col-md-3 col-sm-9 col-xs-12" style="padding-left: 12px; width: inherit;">@Html.TextAreaFor(model => model.Task_runsModel.comment1, new { id = "comment", ariahidden = "true", placeholder = "Write comment", @class = "form-control wp-editor-area", cols = "65", rows = "3", style = " width: calc(100%);" }) </span>
</div>
</fieldset>
</form>
的jQuery:
jQuery(function ($) {
// $('#form_data').validate();
$("#form_data").validate({
messages: {
Project_Id: {
required: "Eh ? empty username ?",
minLength: "At least 4 characters are necessary"
},
Task_Id: {
required: "password missing"
},
status: {
required: "please provide us your email, we promise we wont spam !",
email: "email id is not in correct format, eg: [email protected]"
}
}
});
如果你在你的C#模型和JQuery驗證沒有使用的數據註解突兀,你不應該需要手動掛鉤驗證這樣 – Pete