Click here to Skip to main content
15,886,736 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I am using Clint side validation for a form to submit some not null value and also some null-able Value but my validation not allowing null-able values.

here is my View Model

C#
public int? ResourceId { get; set; }

       public int? Minutes { get; set; }

       [Required(ErrorMessageResourceName = "REQ_Gender", ErrorMessageResourceType = typeof(Resources.Messages))]
       public DateTime BookingDate { get; set; }

       [DataType(DataType.Time)]
       public DateTime? StartTime { get; set; }

       [DataType(DataType.Time)]
       public DateTime? EndTime { get; set; }

       public decimal? Price { get; set; }

       public bool IsFree { get; set; }

       public bool IsCourse { get; set; }

      [StringLength(500)]
       public string Reason { get; set; }

       public DateTime? PaymentDate { get; set; }


       public decimal? PartlyPaidAmount { get; set; }


But on submitting null value to Price and PartlyPaidAmount i am geting a validation msg as
"The field Price must be a number." and "The field PartlyPaidAmount must be a number."
please follow this link to see the result:
https://app.box.com/s/4abvfvsjzt7m6jdk5u47[^]

All i need is to submit the form with null value for Price and PartlyPaidAmount.

Thank you,
Posted
Updated 7-Aug-13 2:50am
v7

1 solution

this happens because you have apply Validate attribute to your hole model, remove validate attribute from your model and apply it to individual where it is mandatory.
Hope this will help you
 
Share this answer
 
Comments
vyas_pratik20 7-Aug-13 9:25am    
inserted of writing [ValidateInput(true)] or nothing on class name set [ValidateInput(false)]
and apply [ValidateInput(true)] on each member for the ex : [ValidateInput(true)] public DateTime BookingDate { get; set; }
vyas_pratik20 7-Aug-13 10:11am    
you should write [ValidateInput(false)] above your class defination, don't apply this to property.
vyas_pratik20 8-Aug-13 5:59am    
if you get the solution mark my answer as accepted
amitcs1990 7-Aug-13 9:00am    
Hello,

I have published a website but it goes down after each 2-3 days.
can you please help me what should i do to continue running my website.

Thanks
Amit Kumar Bhatt
8924834406

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900