asp.net-mvc-validation Questions

5

Solved

I'm using ASP.NET MVC 3 code-first and I have added validation data annotations to my models. Here's an example model: public class Product { public int ProductId { get; set; } [Required(ErrorM...
Ministerial asked 15/6, 2011 at 15:18

4

Solved

I'm messing around with data annotations. When I click on a link to go to a page, the validation messages are being displayed, but I would like to have the validation messages not show unless data ...
Saccharin asked 22/1, 2014 at 23:27

4

Solved

Say you have a standard ValidationSummary: <%: Html.ValidationSummary(excludePropertyErrors: true) %> If the ModelState contains model errors for properties but not for the model itself th...
Siren asked 3/10, 2010 at 11:29

4

Solved

I have an ASP.net MVC model with a date: public class EditModel { [Display(Name="DOB")] public DateTime? DateOfBirth { get; set; } } @Html.TextBoxFor(m => m.DateOfBirth) @Html.ValidationMes...
Merth asked 28/9, 2011 at 16:6

5

Solved

I have got a hidden field with a validation for it as below @Html.HiddenFor(m => m.Rating) @Html.ValidationMessageFor(m => m.Rating) The Rating property has Range validator attribute appli...
Alpine asked 17/10, 2011 at 7:15

1

Solved

I'm trying to inherit the RegularExpressionAttribute to improve reusability with validating SSNs. I have the following model: public class FooModel { [RegularExpression(@"^(?!000)(?!666)(?!9[0-9...

2

Solved

I have a RangeValidator on a property in my model to only allow Integers that are between 0 and 100. I have a partial view that displays a form to update the property via a jQuery UI dialog. I have...

1

Solved

I have an ASP.NET MVC 4 App that uses the jQuery.validation.js plugin and MVC's jQuery.validation.unobtrusive.js. I use data annotations on my view model to validate a textbox's input to be an inte...

4

Solved

I am using a form to upload a file. I want only PDF files to be uploaded. This is my code: A input box to allow the user to choose a file: @Html.FileBox(m => m.FileName, new { id = "FileName",...
Autoplasty asked 8/5, 2012 at 10:36

1

Solved

Working on a MVC 3 application. I need to add a class to the validation message html. I mean for span tag. My Model [Required(ErrorMessage = "Role Name is required")] [RegularExpression(@"^[a-...
Walther asked 9/1, 2013 at 7:4

3

Solved

I have a class user which looks like this: public class User { public int UserId { get; set; } [Required(ErrorMessage = "A username is required.")] [StringLength(20, ErrorMessage = "Your usern...
Herschelherself asked 16/2, 2011 at 23:51

1

Solved

I have a two step form process where the first set of data is stored in session. [IsMp4File] [Required(ErrorMessage = "* Please select a video to upload")] public HttpPostedFileBase VideoClip { ge...

2

Solved

I'm trying to solve a "A potentially dangerous Request.Form value was detected from the client" problem, and SO answers and Scott Hanselman recommend setting <httpRuntime requestValidationMode...

1

Solved

A weird thing keeps happening on one of my ASP.NET MVC 3 apps. I am fetching insert rows via jQuery Ajax api and there is no problem with that. But when I get the necessary partial view back, it i...

2

Solved

I have the following view in ASP.net MVC 3: @model Models.CreateProjectViewModel <script type="text/javascript" src="@Url.Content("~/Scripts/jquery.validate.min.js")"></script> <sc...

4

Solved

I'd like to create a custom validation attribute for MVC2 for an email address that doesn't inherit from RegularExpressionAttribute but that can be used in client validation. Can anyone point me in...
Piperidine asked 5/3, 2010 at 0:8

5

Solved

I can't seem to get any client side validation working on a MVC 2 RC app. My model has the following: public class ExampleModel { [Required(ErrorMessage="Test1 is required")] [DisplayName("Test...
Ishii asked 4/1, 2010 at 2:55

2

Solved

How can I return a list/array of all keys that have an error? I have tried to do the below, but it says I can't have that sort of expression for some reason. ModelState.ToList(item => item.Val...
Mumble asked 20/5, 2009 at 15:11
1

© 2022 - 2024 — McMap. All rights reserved.