MVC4与实体框架无效条目EnrollmentDate [英] MVC4 with Entity Framework Invalid entry for EnrollmentDate

查看:128
本文介绍了MVC4与实体框架无效条目EnrollmentDate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从下面的教程<一个href=\"http://www.asp.net/mvc/overview/older-versions/getting-started-with-ef-5-using-mvc-4/implementing-basic-crud-functionality-with-the-entity-framework-in-asp-net-mvc-application\"相对=nofollow>这里

由于某些原因,当我尝试创建一个带有日期的新用户,除非一个月日期从1-12ish之间一月它不会接受它。

For some reason when I try to create a new user with a date it won't accept it unless the month is January between dates ranging from 1-12ish.

我是pretty相信这是因为ValidationMessageFor的(在User.cs),这迫使我输入一个月必须是一月,我不知道在哪里可以修改它的日期方法。

I'm pretty sure it's because of the ValidationMessageFor(in the User.cs) method which forces me to enter a date which month must be January and I don't know where to alter it.

招生错误

jquery.validate

jquery.validate.unobtrusive

推荐答案

添加code到脚本

$.validator.addMethod('date', function (value, element) {
  if (this.optional(element)) {
    return true;
  }
  var valid = true;
  try {
    $.datepicker.parseDate('dd/mm/yy', value);
  }
  catch (err) {
    valid = false;
  }
  return valid;
});
$('#dt1').datepicker({ dateFormat: 'dd/mm/yy' });

这篇关于MVC4与实体框架无效条目EnrollmentDate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆