阻止空/空字段提交错误消息

时间:2014-12-12 14:09:52

标签: c# sql asp.net-mvc visual-studio-2012 razor

我有一个允许用户将数据输入数据库的表单。我通过触发无效的表单条目显示错误消息的问题。如果我提交带有空字段的表单,会弹出一个红色的预定义错误消息大约一秒钟,但随后html元素会立即转换为页面上的文字文本。我怎样才能防止这种情况发生?

namespace BillingApp.Models
{
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

public partial class AUTHORIZED_USERS
{

    public int USID { get; set; }
    [Required(ErrorMessage = "<br /><font style='color:red;'>Associate name required</font>")]       
    public string FLNAME { get; set; }

    [Required(ErrorMessage = "<br /><font style='color:red;'>SSO ID required</font>")]
    public string UNAME { get; set; }

    [Required(ErrorMessage = "<br /><font style='color:red;'>Security group required</font>")]       
    public string SECURITY_GROUP { get; set; }
}
}

0 个答案:

没有答案
相关问题