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

cascading dropdown loses select items after post

I have an MVC3 razor project, which I am trying to build using multiple reusable elements. I have many model classes like the following public class ProductCreateModel { [Required] [Display(Name = "Org")] …
Mickey
  • 3
  • 2
  • 5
0
votes
1 answer

MVC3: EditorForModel() for non strings

I have a model I would like to use in a form using EditorForModel(). For all non-String data types (like bool, DateTime etc), the form created makes the fields required, even though I have not set the [Required} data annotation. How do I set the…
Mickey
  • 3
  • 2
  • 5
-1
votes
1 answer

ASP.NET Core : TryValidateModel throws NullReferenceException when Controller calls another Controller

I have an ASP.NET Core MVC view that contains different types of entities. The view is handled by a MainController that calls the individual entities' controller based on a discriminator. This has been working fine until I started using custom…
-1
votes
1 answer

i want a validation in my Django model that question field would not accept an integer i try but it's not working..How can i do that?

Here this is my Code #models.py from django.db import models class Question(models.Model): question = models.CharField(max_length=200, null= True) option1 = models.CharField(max_length= 200, null= True) option2 =…
-1
votes
2 answers

Get action info from ModelValidator

I'm implementing a ModelValidator that needs to get reflected information from the executing action. Validation behavior will change depending on how action is decorated. Can I get that information?
Eduardo
  • 5,645
  • 4
  • 49
  • 57
-1
votes
1 answer

Data annotation to allow only whole numbers for long data type properties

I have a class as below, public class MyClass { [Required] public string Name { get; set; } [Required] [Range(1, Int64.MaxValue)] public long Volume{ get; set; } } And used the above class in…
Magendran V
  • 1,411
  • 3
  • 19
  • 33
-1
votes
1 answer

ASP.NET jQuery unobtrusive model validation injecting data-val-required without required data annotation

Why is my strongly type html having a data-val-required attribute even though I didn't specified in my model property to be required? Here is my model class public class Document { public string Name { get; set; } public bool IsConfirmed {…
Bon Macalindong
  • 1,310
  • 13
  • 20
-1
votes
1 answer

Custom validation for Age must be greater than or equal to 18

I want to make custom validation for date where Age is greater than or equal to 18. Can any one idea with mvc4 with custom validation? Please let me know if any solution is there.. Regards
-2
votes
2 answers

Regex to allow only alphanumerics with at least one character and no empty space

I keep trying everything from the search result (google) but without success till now. For my username input I want only to allow alphanumerics, without empty spaces and no tabs. The username can have a combination of letters and numbers, but must…
Tinaira
  • 727
  • 2
  • 7
  • 23
-2
votes
2 answers

C# string should not contain only white spaces or any special character except ,.';:"

I need a regular expression pattern to verify string does not contain only white spaces(blank with multiple space only)(Ex: " ".length = 4) and should not contain !@$#%^&*() characters. Regex regex = new Regex(@".\S+."); This one checks for white…
Sipun
  • 11
  • 5
1 2 3
21
22