最近项目中用了mvc自带的ajax验证,但是在项目中遇到了点问题,就是验证提示时会显示英文。像下面这样:
在网上找了好多文章,但是都不是解决办法。最后在这篇文章看到可能有解决办法,但是他这种自定义的方法我没有尝试。由于自己用的mvc4所以看到评论有人提醒,就用了这种方式解决了
@Html.TextBoxFor(model => model.TrainDay, new { @class = "input", data_val_number = "请输入有效的天数"})
下面说说mvc自带验证的用法
1.我使用了viewmodel,所以验证信息都加在viewmodel了,代码(部分)如下:
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
namespace CustomsProjectEx.Web.Areas.SAM.Models
{
public class VMContract