All Questions

0
votes
0answers
9 views

Remote Validation Not working on MVC project, date is not validating for duplicates

Controller has a JsonResult which checks if pickupDate from datebase is equal to the pickupdate entered on Client side public JsonResult pickupdateExist (string pickupDate) { ...
0
votes
1answer
16 views

How to validate list of ViewModel and display error messages on UI

I am working on a web api project where there is a domain as below, public class Customer { public string Email { get; set; } } ViewModel is defined as, public class CustomerViewModel { [...
0
votes
1answer
45 views

Validation always fired for fields dynamically added with partial view

Using a main view and partial view to add fields dynamically to it with ModelViews. The issue is the ModelState.isValid always returns falls because there are 2 fields in the partial view which are ...
3
votes
2answers
298 views

ASP.NET MVC ViewModel validation and Single Responsibility Principle [closed]

The most common approach I've seen in online examples when it comes to validation in MVC is to use the ViewModel to validate the data. People either use Data Annotations or implement ...
0
votes
0answers
120 views

Html.ValidationSummary: Make two different messages for one property depending on some values

here's my question. I have a ViewModel with some string property. I have a client validation for that property and what's more this client validation has two messages depending on some other boolean ...
4
votes
3answers
3k views

Data validation for every item in a list of my ViewModel

To make a validation with a Regex, I usually do: // In my ViewModel [RegularExpression("MyRegex", ErrorMessageResourceName = "MyErrorMessage")] public string MyField { get; set; } And the HTML ...
1
vote
2answers
650 views

How to make a something required AND use a regular expression attribute?

I have a viewmodel that works fine EXCEPT if the person enters nothing and hits submit, then i get a db error because the column doesn't except nulls. I am doing if (ModelState.IsValid) How can I ...
0
votes
1answer
2k views

validate a field in the viemodel before submit mvc

I have a viewModel that implements custom validators: public class RegistrationViewModel { #region country public int CountryId { get; set; } public List<SelectListItem> Countries {...
3
votes
2answers
2k views

MVC validation lost in Knockoutjs post

I'm using MVC4 and knockout. I have a form on a page that is strongly typed to a viewmodel. In that viewmodel I have some validation defined, for instance: [Required(ErrorMessage = "Title is required"...
0
votes
1answer
281 views

validation failing on dropdown MVC

I am using code-first with EF. Validation seems to be failing on a dropdown list with the error System.NullReferenceException: Object reference not set to an instance of an object. This happens when I ...
4
votes
1answer
7k views

MVC3 Custom Validation error message doesn't display when using ViewModel

SUMMARY Question: Why doesn't the custom validation error message show when using a ViewModel. Answer: The custom validation should be applied to the ViewModel not the Class. See the end of @...