Questions tagged [model-validation]

Model Validation is ASP.NET MVC validation method for your models with property attributes. Model validation works for client and server side validation.

For further information you can check Scott Gu's blog post: http://weblogs.asp.net/scottgu/archive/2010/01/15/asp-net-mvc-2-model-validation.aspx

There is a expansion called "DATA ANNOTATIONS EXTENSIONS" for other custom validation types such as CreditCard, min-max integer value etc. http://weblogs.asp.net/srkirkland/archive/2011/02/23/introducing-data-annotations-extensions.aspx

325 questions
0
votes
1 answer

database first data annotation Issue asp.net mvc 4

I'm having trouble using database first approach model validations, i read famous ASP.NET MVC 2: Model Validation by Scott Gu, but the problem is it did not work in my mvc project, I'm having my Edmx file in Project.Model class library ,and my…
0
votes
1 answer

Extending PartialViewResult, Model isn't validated?

I've got a class which extends PartialViewResult and in this class I'm setting the Response.StatusCode and the Model via ViewData. My model and statuscode are getting set as I'd expect, but my model isn't validated. Are their additional steps needed…
dougajmcdonald
  • 19,231
  • 12
  • 56
  • 89
0
votes
2 answers

MVC validator for integer array in model

I have used validator required field in my model as follow and its working [Required(ErrorMessage = "Description is required.")] public string Description { get; set; } Now i have another property of integer array type public string[]…
rahularyansharma
  • 11,156
  • 18
  • 79
  • 135
0
votes
1 answer

how to check validation error on submit button click in MVC?

I have one View and in which there 3 partial views are rendering. And there is one Save button on the parent view(Index,in which the partial views are rendering).This Save button is common for all of the partial views. My problem is, i am not…
Pawan
  • 2,150
  • 11
  • 45
  • 73
0
votes
1 answer

Change Error message in multi-languages in Cakephp

I need to change the error messages based on the language changes. i have created default.po file in the /locale/en/LC_MESSAGES/default.po in that have created msgid as ID-1 and same way did it for spain /locale/spa/LC_MESSAGES/default.po in view…
0
votes
2 answers

inheriting multiple metadatatypes

This seems like a simple one but I have a feeling that the Framework won't let me do what I want it to do. Let's say I have 3 pages - one that asks for firstname/lastname, one that asks for phone number, and one that lets you edit both: public…
benpage
  • 4,418
  • 3
  • 41
  • 39
0
votes
0 answers

Validation with request to the database

I have three models : User, Product and Loan. A loan has a borrowing_date, a returning_date and a current boolean. I want to prevent a user to ask borrowing a product more than once. I want to prevent my loan model to have more than one current…
Flo Rahl
  • 1,044
  • 1
  • 16
  • 33
0
votes
2 answers

Custom model & client validation in MVC without data annotations

I have the below view models, which are used to represent a survey of questions, but they are structured into a more flattened grid to accommodate the default model binder. // Main ViewModel for the Question View public class SurveyRowList { …
Pricey
  • 5,799
  • 12
  • 60
  • 84
0
votes
1 answer

Conditional regex in model validation

I am new to regex and am validating a phone number. If the phone number starts with 011. The number can be greater than 10 digits. If it doesn't start with 011 it must be between 10-15 digits. Currently I have (?(011)\d{10, 15}|\d{7,}) but that is…
userNick
  • 27
  • 3
0
votes
1 answer

ModelState.IsValid is always false for RegularExpression ValidationAttribute in MVC 4

In my class, I have a property for a file attachment like so... public class Certificate { [Required] // TODO: Wow looks like there's a problem with using regex in MVC 4, this does not work! …
0
votes
1 answer

How to validate multiple models in asp.net mvc 3?

I have a simple model like: public class AppointmentModel { private static List _list; public string ClientName { get; set; } [DataType( DataType.Date )] public DateTime Date { …
Snake Eyes
  • 16,287
  • 34
  • 113
  • 221
0
votes
2 answers

Model Form validation is not working...I dont get why

model.py from django.core.exceptions import ValidationError def surname_validate(value): if value == "123": raise ValidationError('is not an even number') class…
flexxxit
  • 2,440
  • 5
  • 42
  • 69
0
votes
1 answer

Localized modelvalidation not working in ie < 9

I'm using localized modelvalidation in my mvc 3 application. I did this with the Required attribute and a errormessage resource. This works on almost all browsers, except ie 7 and 8. Below you can find the sample code that I used. Sample code: …
Patrick
  • 2,730
  • 4
  • 33
  • 55
0
votes
2 answers

.Net Data annotation and model hierarchy

everyone! I'm confusing with implementing a piece of code to make work .net data annotation in asp.net mvc 3 with model with different required fields in several cases (6). I have a model: public class OpportunityModel { public Guid…
Roman
  • 565
  • 1
  • 10
  • 27
0
votes
1 answer

Required ModelValidation just for new objects ASP.NET MVC

I have this issue since yesterday. In my User model I have a [NotMapped] called "ConfirmPassword". I don´t save it on the database but I use it on my Create form as a always to validate the data input for new users. Since than, it´s ok. The problem…
1 2 3
21
22