MVC 4无线电按钮验证与不引人注目的验证

时间:2013-11-19 15:30:51

标签: jquery asp.net-mvc validation radio-button unobtrusive-validation

在获取单选按钮进行验证时遇到一些麻烦。只有我的文本字段和文本区域正在验证。我在互联网上发现的一些文章中尝试了一些东西,并在这里提出了一些问题,但是我遇到了一个死胡同。

这是我的代码:

查看

@using(Html.BeginForm("Submit", "Call_For_Entries", FormMethod.Post, new { @class = "contactForm" }))
    {
        @Html.AntiForgeryToken()

        @Html.ValidationSummary()

        <div class="form-wrap">
            <div class="form-left">
                <h4>CATEGORY OF SUBMISSION</h4>

                @Html.RadioButtonFor(m => m.submissionCategory, "Design (Making, Industrial Design, Textiles, Architechure, Robotics, etc)", new { id = "Design" }) 
                <label for="Design"><span class="button"></span> <span class="text">Design (Making, Industrial Design, Textiles, Architechure, Robotics, etc)</span></label><br />

                @Html.RadioButtonFor(m => m.submissionCategory, "Entertainment (Gaming, Toys, Digital Media, etc)", new { id = "Entertainment" }) 
                <label for="Entertainment"><span class="button"></span> <span class="text">Entertainment (Gaming, Toys, Digital Media, etc)</span></label><br />

                @Html.RadioButtonFor(m => m.submissionCategory, "Information Architecture (Big Data, Computing, Communications, etc)", new { id = "InformationArchitechure" }) 
                <label for="InformationArchitechure"><span class="button"></span> <span class="text">Information Architecture (Big Data, Computing, Communications, etc)</span></label><br />

                @Html.RadioButtonFor(m => m.submissionCategory, "Fine Arts (Interactive arts, 4D, Art + Technology)", new { id = "FineArts" }) 
                <label for="FineArts"><span class="button"></span> <span class="text">Fine Arts (Interactive arts, 4D, Art + Technology)</span></label><br />

                @Html.RadioButtonFor(m => m.submissionCategory, "Software (Mobile Apps, Augmented Reality, Health IT, etc)", new { id = "Software" }) 
                <label for="Software"><span class="button"></span> <span class="text">Software (Mobile Apps, Augmented Reality, Health IT, etc)</span></label><br />

                @Html.RadioButtonFor(m => m.submissionCategory, "Education (Education Technologies, Children & Youth)", new { id = "Education" }) 
                <label for="Education"><span class="button"></span> <span class="text">Education (Education Technologies, Children & Youth)</span></label><br />

                @Html.RadioButtonFor(m => m.submissionCategory, "Community (Art + Technology community programs, events or projects)", new { id = "Community" }) 
                <label for="Community"><span class="button"></span> <span class="text">Community (Art + Technology community programs, events or projects)</span></label><br />

                @Html.RadioButtonFor(m => m.submissionCategory, "Student (Higher Education projects)", new { id = "Student" }) 
                <label for="Student"><span class="button"></span> <span class="text">Student (Higher Education projects)</span></label>

                <label for="entryTitle" class="strong">TITLE OF ENTRY</label>
                @Html.TextBoxFor(m => m.entryTitle)

                <label for="entryDesc" class="strong">ENTRY DESCRIPTION <span class="small">(200 characters or less)</span></label>
                @Html.TextAreaFor(m => m.entryDesc)
            </div>
    }

MODEL

    [Key]
    public int ID { get; set; }

    [Required(ErrorMessage = "Please enter a submission category.")]
    public string submissionCategory { get; set; }

    [Required(ErrorMessage = "Please enter an entry title.")]
    public string entryTitle { get; set; }

    [Required(ErrorMessage = "Please enter an entry description.")]
    public string entryDesc { get; set; }

0 个答案:

没有答案