Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7583335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:39:09+00:00 2026-05-30T18:39:09+00:00

I have a very odd problem with unobtrusive validation. I have a model with

  • 0

I have a very odd problem with unobtrusive validation.

I have a model with a Required attribute on three stirng properties. I’m using TextBoxFor for two of the fields, and TextAreaFor for the last. The validation is working on the TextArea, but NOT on the input fields. Looking at the source, I can see that the attributes that the validation adds are not on the inputs, but ARE on the text box. Additionally, if I enter data into the text box and submit, it posts and MVC model binding DOES correctly set ModelState.IsValid to false and the ValidationSummary shows the fields.

What would cause the validation to not work on the input elements?

Model:

    public class TestModel : IEmail {
        public string BCCAddresses {
            get;
            set;
        }

        [Required]
        public string BodyFormat {
            get;
            set;
        }

        public string CCAddresses {
            get;
            set;
        }

        [Required]
        public string FromAddress {
            get;
            set;
        }

        [Required]
        public string SubjectLineFormat {
            get;
            set;
        }
  }

View:

@section head {
    <script src="@Url.Content( "~/Scripts/jquery.1.7.1.min.js" )" type="text/javascript"></script>
    <script src="@Url.Content( "~/Scripts/jquery.validate.min.js" )" type="text/javascript"></script>
    <script src="@Url.Content( "~/Scripts/jquery.validate.unobtrusive.min.js" )" type="text/javascript"></script>

}


@{
    Html.EnableClientValidation();
    Html.EnableUnobtrusiveJavaScript();
}

            @using ( Html.BeginForm( "Edit", "Email", FormMethod.Post ) ) {
                <table>
                    <tr>
                        <td>From</td>
                        <td>@Html.TextBoxFor( x => x.FromAddress, new { style = "width: 500px;" } )</td>
                    </tr>
                    <tr>
                        <td>CC</td>
                        <td>@Html.TextBoxFor( x => x.CCAddresses, new { style = "width: 500px;" } )</td>
                    </tr>
                    <tr>
                        <td>BCC</td>
                        <td>@Html.TextBoxFor( x => x.BCCAddresses, new { style = "width: 500px;" } )</td>
                    </tr>
                    <tr><td colspan="2">&nbsp;</td></tr>
                    <tr>
                        <td colspan="2">Subject Line</td>
                    </tr>
                    <tr>
                        <td colspan="2">@Html.TextBoxFor( x => x.SubjectLineFormat, new { style = "width: 500px;" } )</td>
                    </tr>
                    <tr><td colspan="2">&nbsp;</td></tr>
                    <tr>
                        <td colspan="2">Body Form</td>
                    </tr>
                    <tr>
                        <td colspan="2">@Html.TextAreaFor( x => x.BodyFormat, new { style = "width: 500px; height: 200px" } )</td>
                    </tr>
                    <tr><td colspan="2">&nbsp;</td></tr>
                    <tr>
                        <td colspan="2">
                            <input id="ApplyChanges" type="submit" class="NavigationButton"  value="Save Changes" /> 
                            <input id="CancelChanges" type="button" class="NavigationButton" value="Cancel Changes" />
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            @Html.ValidationSummary()
                        </td>
                    </tr>
                    <tr><td colspan="2">&nbsp;</td></tr>
                </table>
            }

Browser source:

<form action="/url" method="post">
                <table>
                    <tbody><tr>
                        <td>From</td>
                        <td><input style="width: 500px;" id="FromAddress" name="FromAddress" value="" type="text"></td>
                    </tr>
                    <tr>
                        <td>CC</td>
                        <td><input style="width: 500px;" id="CCAddresses" name="CCAddresses" value="" type="text"></td>
                    </tr>
                    <tr>
                        <td>BCC</td>
                        <td><input style="width: 500px;" id="BCCAddresses" name="BCCAddresses" value="" type="text"></td>
                    </tr>
                    <tr><td colSpan="2">&nbsp;</td></tr>
                    <tr>
                        <td colSpan="2">Subject Line</td>
                    </tr>
                    <tr>
                        <td colSpan="2"><input style="width: 500px;" id="SubjectLineFormat" name="SubjectLineFormat" value="" type="text"></td>
                    </tr>
                    <tr><td colSpan="2">&nbsp;</td></tr>
                    <tr>
                        <td colSpan="2">Body Form</td>
                    </tr>
                    <tr>
                        <td colSpan="2"><textarea style="width: 500px; height: 200px;" id="BodyFormat" cols="20" rows="2" name="BodyFormat" data-val-required="The BodyFormat field is required." data-val="true"></textarea></td>
                    </tr>
                    <tr><td colSpan="2">&nbsp;</td></tr>
                    <tr>
                        <td colSpan="2">
                            <input id="ApplyChanges" class="NavigationButton" disabled="disabled" value="Save Changes" type="submit"> 
                            <input id="CancelChanges" class="NavigationButton" value="Cancel Changes" type="button">
                        </td>
                    </tr>
                    <tr>
                        <td colSpan="2">
                            <div class="validation-summary-valid" data-valmsg-summary="true"><ul><li style="display: none;"></li>
</ul></div>
                        </td>
                    </tr>
                    <tr><td colSpan="2">&nbsp;</td></tr>
                </tbody></table>
</form>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T18:39:10+00:00Added an answer on May 30, 2026 at 6:39 pm

    I performed a quick test with almost your identical sample code and the validation is working fine on my end. I would start stripping items back until you find what is conflicting with your validation.

    For references here is what my test looked like:

    Controller:

    public ActionResult Index()
    {
        var model = new TestModel();
        return View("Index", model);
    }
    

    The test model I used did not inherit from ” IEmail”:

    public class TestModel
    {
        public string BCCAddresses
        {
            get;
            set;
        }
    
        [Required]
        public string BodyFormat
        {
            get;
            set;
        }
    
        public string CCAddresses
        {
            get;
            set;
        }
    
        [Required]
        public string FromAddress
        {
            get;
            set;
        }
    
        [Required]
        public string SubjectLineFormat
        {
            get;
            set;
        }
    }
    

    And my view was pretty much identical. Note, that I did not implement a section for the script libraries but directly referenced them within thew view. EG:

    <script src="@Url.Content("~/Scripts/jquery.1.7.1.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
    

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Django's message framework, and I have a very odd problem where my
i have very simple problem. I need to create model, that represent element of
I have a very odd problem. A class property is mysteriously reset between method
I am having a very odd problem with Visual Studio 2010. After using it
We have a very odd problem here with SVN. Let me first explain the
This is my first question on S.O. I have a very odd problem. Below
I have a very odd problem with javascript. My code is rather long so
I have a very odd problem with Flash 10 and ExternalInterface. I am currently
I have a very odd problem. Whenever I try to use the Add View
I have a very odd problem where live wallpapers will not work right on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.