表单验证后提交
form submit after validation
我想停止由 models 属性完成的客户端验证提交的表单。我已经尝试了所有的可能性,但没有成功。请看这段代码:
我的模特是
[Key]
public int User_ID { get; set; }
[Required(ErrorMessage = "* Please Enter FirstName")]
public string User_FN { get; set; }
[Required(ErrorMessage = "* Please Enter MiddleName")]
public string User_MN { get; set; }
[Required(ErrorMessage = "* Please Enter LastName")]
public string User_LN { get; set; }
[Required(ErrorMessage = "* Please Enter LoginID")]
public string User_Login { get; set; }
[Required(ErrorMessage = "* Please Enter PassWord")]
public string User_Password { get; set; }
[Required(ErrorMessage = "* Please Select a Valid Role")]
public int User_Role_ID { get; set; }
[Required(ErrorMessage = "* Please Select any one Table")]
public List<int> Table_ID { get; set; }
[Required]
public List<bool> P_Add { get; set; }
[Required]
public List<bool> P_Edit { get; set; }
[Required]
public List<bool> P_Delete { get; set; }
并且我添加了这个参考 jquery 文件
<script src="~/Scripts/jquery.validate.unobtrusive.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
<script src="~/Scripts/jquery.validate.js"></script>
并将这些键设置为
<appSettings>
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true"/>
<add key="UnobtrusiveJavaScriptEnabled" value="true"/>
</appSettings>
所有设置都已完成,但页面仍然提交...请建议我
您需要在 validate.unobtrusive.min.js
之前加载 validate.js
我想停止由 models 属性完成的客户端验证提交的表单。我已经尝试了所有的可能性,但没有成功。请看这段代码:
我的模特是
[Key]
public int User_ID { get; set; }
[Required(ErrorMessage = "* Please Enter FirstName")]
public string User_FN { get; set; }
[Required(ErrorMessage = "* Please Enter MiddleName")]
public string User_MN { get; set; }
[Required(ErrorMessage = "* Please Enter LastName")]
public string User_LN { get; set; }
[Required(ErrorMessage = "* Please Enter LoginID")]
public string User_Login { get; set; }
[Required(ErrorMessage = "* Please Enter PassWord")]
public string User_Password { get; set; }
[Required(ErrorMessage = "* Please Select a Valid Role")]
public int User_Role_ID { get; set; }
[Required(ErrorMessage = "* Please Select any one Table")]
public List<int> Table_ID { get; set; }
[Required]
public List<bool> P_Add { get; set; }
[Required]
public List<bool> P_Edit { get; set; }
[Required]
public List<bool> P_Delete { get; set; }
并且我添加了这个参考 jquery 文件
<script src="~/Scripts/jquery.validate.unobtrusive.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
<script src="~/Scripts/jquery.validate.js"></script>
并将这些键设置为
<appSettings>
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true"/>
<add key="UnobtrusiveJavaScriptEnabled" value="true"/>
</appSettings>
所有设置都已完成,但页面仍然提交...请建议我
您需要在 validate.unobtrusive.min.js
之前加载 validate.js