Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery MVC 5客户端验证文化_Jquery_Asp.net Mvc_Validation_Culture_Globalize - Fatal编程技术网

Jquery MVC 5客户端验证文化

Jquery MVC 5客户端验证文化,jquery,asp.net-mvc,validation,culture,globalize,Jquery,Asp.net Mvc,Validation,Culture,Globalize,我将Web.config文件中的区域性更改为es CL,服务器端验证工作正常,但当我尝试提交数据时,客户端验证会在2016年11月25日等日期出现错误,因为它仍然使用英语日期格式,如2016年11月25日 我发现这篇文章差不多,但日期改为小数: 问题是所有的答案都过时了,因为更新的全球化插件不再使用全球化文件,比如globalize.culture.es-CL.js在包中不存在。(或者我遗漏了什么?) 如何将客户端验证区域性设置为es CL或es MX 以下是我的查看代码: &l

我将
Web.config
文件中的区域性更改为es CL,服务器端验证工作正常,但当我尝试提交数据时,客户端验证会在2016年11月25日等日期出现错误,因为它仍然使用英语日期格式,如2016年11月25日

我发现这篇文章差不多,但日期改为小数:

问题是所有的答案都过时了,因为更新的全球化插件不再使用全球化文件,比如
globalize.culture.es-CL.js
在包中不存在。(或者我遗漏了什么?)

如何将客户端验证区域性设置为es CL或es MX

以下是我的查看代码:

        <div class="form-group">
            @Html.LabelFor(model => model.ReleaseDate, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @* i set the @type = "text" because i will use a Jquery DatePicker instead the browser's DatePicker, and the @class = datepicker adds the DatePicker. *@
                @Html.EditorFor(model => model.ReleaseDate, new { htmlAttributes = new { @class = "form-control datepicker", @type = "text" } })
                @Html.ValidationMessageFor(model => model.ReleaseDate, "", new { @class = "text-danger" })
            </div>
        </div>
控制器操作:

public ActionResult Edit(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            Movie movie = db.Movies.Find(id);
            if (movie == null)
            {
                return HttpNotFound();
            }
            return View(movie);
        }

谢谢。

使用
@Html.EditorFor()
然后使用
新建{type=“text”}
没有任何意义,它应该是
@Html.TextBoxFor(m=>m.ReleaseDate,new{@class=“form control datepicker”})
。和
[DataType(DataType.Date)]
以及
[DisplayFormat]
ApplyFormatInEditMode=true
属性只有在使用
EditorFor()
时才受尊重,而不重写
type
属性,因此这两个属性都应该被删除。您需要重写
$.validator
(根据
MM/dd/yyyy
格式验证日期)。您的
class=“datepicker”
建议您可能正在使用jquery插件,因此请参考jquery ui datepicker,或者您是否找到了解决方案?我面临着完全相同的问题…使用
@Html.EditorFor()
然后
新建{type=“text”}
没有任何意义,它应该只是
@Html.TextBoxFor(m=>m.ReleaseDate,new{@class=“form control datepicker”}
)和
[DataType(DataType.Date)]
以及
[DisplayFormat]
ApplyFormatInEditMode=true
属性,只有在使用
EditorFor()时才受尊重
而不重写
类型
属性,因此这两个属性都应该被删除。您需要重写
$.validator
(它基于
MM/dd/yyyy
格式验证日期)。您的
class=“datepicker”
建议您可能正在使用jquery插件,请参考jquery ui日期选择器,或者您找到解决方案了吗?我面临着完全相同的问题。。。
public ActionResult Edit(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            Movie movie = db.Movies.Find(id);
            if (movie == null)
            {
                return HttpNotFound();
            }
            return View(movie);
        }