我正在尝试使用jquery验证通过mvc模型打印我的自定义消息,但仍然是打印默认消息而不是我指定的消息
代码:
模型 public class Task_runsModel // user使用它来添加任务和注释 { public int Task_Run_Id {get;组; }
[Required(ErrorMessage = "You can't leave this empty.", AllowEmptyStrings = false)]
public int Project_Id { get; set; }
public string start_time { get; set; }
public string end_time { get; set; }
public int dead { get; set; }
[Required(ErrorMessage = "You can't leave this empty.", AllowEmptyStrings = false)]
[Range(0, int.MaxValue, ErrorMessage = "You can't leave this empty.")]
public int Task_Id { get; set; }
public int Active { get; set; }
public DateTime timestamp_dtm { get; set; }
public int UserId { get; set; }
[Required(ErrorMessage = "You can't leave this empty.", AllowEmptyStrings = false)]
public string status { get; set; }
public decimal duration { get; set; }
public string comment1 { get; set; }
public string Task_Name { get; set; }
public string Project_Name { get; set; }
}
HTML:
<div id="add_task_dialog_box" class="hide">
@using (Html.BeginForm("SaveEvent", "Base", FormMethod.Post, new { id = "form_data", @class = "form-horizontal", style = "display: none;" }))
{
@Html.ValidationSummary(true)
@Html.AntiForgeryToken()
<fieldset class="form-group">
<div>
<label class="control-label col-xs-12 col-sm-3 no-padding-right " style="font-weight: bold;
font-size: 13px; text-align: left; font-family: Arial Unicode MS;">
Project Name</label>
<div class="col-xs-12 col-sm-9">
<div class="clearfix">
@Html.DropDownListFor(model => model.Task_runsModel.Project_Id, db.getProjects(a), "--Select--", new { style = "width:200px;", id = "myproject" })
</div>
</div>
</div>
<div>
<label class="control-label col-xs-12 col-sm-3 no-padding-right ">
</label>
<div class="col-xs-12 col-sm-9">
<div class="clearfix">
@Html.ValidationMessageFor(model => model.Task_runsModel.Project_Id, String.Empty, new { @class = "id_form_valid error" })
</div>
</div>
</div>
<br />
<br />
<div class="space-6">
</div>
<div>
<label class="control-label col-xs-12 col-sm-3 no-padding-right " style="font-weight: bold;
font-size: 13px; text-align: left; font-family: Arial Unicode MS;">
Select Task</label>
<div class="col-xs-12 col-sm-9">
<div class="clearfix">
@Html.DropDownListFor(model => model.Task_runsModel.Task_Id, db.getTasks(a, c), "--Select--", new { style = "width:200px;", id = "mytask" })
</div>
</div>
</div>
<div>
<label class="control-label col-xs-12 col-sm-3 no-padding-right ">
</label>
<div class="col-xs-12 col-sm-9">
<div class="clearfix validation-summary-valid">
@Html.ValidationMessageFor(model => model.Task_runsModel.Task_Id, String.Empty, new { @class = "id_form_valid error" })
</div>
</div>
</div>
<br />
<br />
<div class="space-6">
</div>
<div>
<label class="control-label col-xs-12 col-sm-3 no-padding-right " style="font-weight: bold;
font-size: 13px; text-align: left; font-family: Arial Unicode MS;">
Status</label>
<div class="col-xs-12 col-sm-9">
<div class="clearfix">
@Html.DropDownListFor(model => model.Task_runsModel.status, db.getStatus(), "---Select---", new { style = "width:200px", id = "taskstatus", name = "taskname" })
</div>
</div>
</div>
<div>
<label class="control-label col-xs-12 col-sm-3 no-padding-right ">
</label>
<div class="col-xs-12 col-sm-9">
<div class="clearfix">
@Html.ValidationMessageFor(model => model.Task_runsModel.status, String.Empty, new { @class = "id_form_valid error" })
</div>
</div>
</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="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>
}