Wednesday, 15 July 2015

c# - Datatype.Date how to set minimum date to Today? -


itemprop = "text">

I created a datepicker using MVC5 DataType.Date:

  [data type (Data Type Date)] Public Date Time Arrival Date {Received; Set; }  

Can I set at least available dates for today and disable all past dates?

Alternatively, is there an option to disable a custom range of dates?

I have tried to create a custom DateRangeValidator using that, but with that I get the following error:

Here's my date range validator:

  Public Date Time First Date = Date Time Today.Date; // Get Public Datetime Secondend {Receive; Set; } Protected Override ValidationResult if (DATETIME date, ValidationContext validationContext) {// your validation logic (if date> = DbFunctions.TruncateTime (FirstDate)) {return ValidationResult.Success; } And {new verification return ("date is not valid."); }}  

"itemprop =" lesson ">

try creating a custom accreditation feature with your own logic :

  Public Seal Class PresentOrFutureDateAttribute: ValidationAttribute {Protected Override ValidationResult if (Object Value, validationContext validationContext) {// Your Validation Logic (Convert.ToDateTime (Value) & gt; = DateTime Today) {return ValidationResult.Success; } And {new verification return ("previous date is not allowed."); }}}  

No comments:

Post a Comment