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 7521493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:14:38+00:00 2026-05-30T02:14:38+00:00

Im sitting here scratching my head with a validation problem in ASP MVC3. Somehow

  • 0

Im sitting here scratching my head with a validation problem in ASP MVC3.

Somehow I’m able to validate the field Quantity, but the field OrderNumber does not validate. I can leave it empty and it still accepts it. I’ve tried to add other restrictions to it as well (such as max and min length) but same result – it accepts anything.

I also try changing ‘TextBoxFor’ to ‘EditorFor’ – but it’s the same result.

Quantity on the other hand works as I want it. It requires you to enter an integer and it cannot be blank.

Hopefully some of you will be able to see what I’m doing wrong here 🙂

Here is my model:

public class Order
{
    [Required(ErrorMessage="Insert Ordernumber (6-digits)")]
    public string OrderNumber { get; set; }

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

    [Required]
    public long Quantity { get; set; }

    public Order()
    {
    }
}

And here is my view :

model POWeb.Models.AddModel

@using (Html.BeginForm(“Add”, “Home”, FormMethod.Post))
{

//Create table
<table>
    <tr>
        <td>Select Partnumber to produce</td>
        <td>@Html.DropDownListFor(model => model.SelectedPartNumber, Model.PartNumbers)</td>
    </tr>

    <tr>
        <td>Enter PO number</td>
        <td>@Html.TextBoxFor(model => model.OrderNumber)@Html.ValidationMessageFor(model => model.OrderNumber)</td>
    </tr>

    <tr>
        <td>Quantity</td>
        <td>@Html.TextBoxFor(model => model.Quantity)@Html.ValidationMessageFor(model => model.Quantity)</td>
    </tr>

    <tr>
        <td colspan="2">
            <button type="submit" name="SubmitButton">Add</button>
        </td>
    </tr>

</table>

}

  • 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-30T02:14:38+00:00Added an answer on May 30, 2026 at 2:14 am

    You have the view of type POWeb.Models.AddModel, but you try to validate Order type. I’m pretty sure validation attributes on those types are not the same, so you get problems

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

Sidebar

Related Questions

I'm sitting here scratching my head here, I should have 2 rows of 4
This is easy for me to perform in TSQL, but I'm just sitting here
I have been scratching my head on this for a while now but still
I'm sitting here with The Good Parts in hand but I'm still none the
I was sitting here wondering if it's possible to write a greasemonkey script that
Click here to see what I mean.. What could prevent these two from sitting
I can't resolve this issue, I found a similar question here but: setting the
Just a small SVN problem here. I setup my own SVN server Setting up
This is a kind of open question. I always keep scratching my head when
Been sitting here for hours now trying to figure this out, so a bit

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.