I am newer to using MVC. I am trying to set up client-side validation using the build in data annotations. I have read a few tutorials but can't seem to get it to work. When I click my form submit button, it still POSTS instead of displaying the error message to inform me no description was provided. Below is my class code and my view code:
Class Code:
using System.ComponentModel.DataAnnotations;
namespace TicketSystem.Models
{
using System;
using System.Collections.Generic;
public partial class TICKET
{
public decimal id { get; set; }
public string empId { get; set; }
public short severityId { get; set; }
public short statusId { get; set; }
public short categoryId { get; set; }
[Required(ErrorMessage = "Description is required!!")]
public string description { get; set; }
public string logOfActions { get; set; }
public string deviceType { get; set; }
public string deviceSerNum { get; set; }
public System.DateTime dateCreated { get; set; }
}
}
View Code:
@Html.LabelFor(m => m.description, "Description:")
@Html.EditorFor(m => m.description, new { rows = 5, @class = "txtBoxDescr" })
@Html.ValidationMessageFor(m => m.description)