I need to extra text into the picker as you see below.
For the hour section, I need to add Stunden (Hour(s) is ) and for the minute section I need to add Min.
I am using Xamarin/MAUI but in this case I access native code. So how can I change these texts in native?
Here is my code. I changed the Interval as you see, and now I need to add text to the sections.
protected override void OnElementChanged(ElementChangedEventArgs<TimePicker> e)
{
base.OnElementChanged(e);
if (Control == null)
return;
var timePicker = (UIDatePicker)Control.InputView;
timePicker.MinuteInterval = 5;
Control.BackgroundColor = UIColor.Clear;
Control.BorderStyle = UITextBorderStyle.None;
Control.TextColor = UIColor.Black;
if (!Control.Enabled)
Control.TextColor = UIColor.LightGray;
if (Control.Focused)
Control.TextColor = UIColor.FromRGB(154, 23, 47);
}
It is not possible to add extra text in TimePicker, you can use the Picker control to customize the content to achieve this effect, I wrote and tested the following code, you can refer to:
Custom Picker code:
public class CustomPicker:UIPickerView
{
public string SelectedHour { get; set; }
public string SelectedMinute { get; set; }
List<string> hours = new List<string>() {
"0 Sunden",
"1 Sunden",
"2 Sunden",
"3 Sunden",
"4 Sunden",
"5 Sunden",
"6 Sunden",
"7 Sunden",
"8 Sunden",
"9 Sunden",
"10 Sunden",
"11 Sunden",
"12 Sunden",
"13 Sunden",
"14 Sunden",
"15 Sunden",
"16 Sunden",
"17 Sunden",
"18 Sunden",
"19 Sunden",
"20 Sunden",
"21 Sunden",
"22 Sunden",
"23 Sunden"
};
List<string> minutes = new List<string>()
{
"0 Min.",
"5 Min.",
"10 Min.",
"15 Min.",
"20 Min.",
"25 Min.",
"30 Min.",
"35 Min.",
"40 Min.",
"45 Min.",
"50 Min.",
"55 Min."
};
public CustomPicker() {
this.DataSource=new PickerViewDateSource(hours, minutes);
this.Delegate=new PickerViewDelegate(hours, minutes, (SelectedHour) =>
{
this.SelectedHour = SelectedHour;
},(SelectedMinute)=>{
this.SelectedMinute = SelectedMinute;
});
}
}
PickerViewDelegate:
public class PickerViewDelegate : UIPickerViewDelegate
{
public Action<string> OnSelectedHour { get; set; }
public Action<string> OnSelectedMinute { get; set; }
public List<string> hours { get; set; }
public List<string> minutes { get;set; }
public PickerViewDelegate(List<string> _hours,List<string> _minuts,Action<string> hourAction,Action<string> minuteAction) {
hours = _hours;
minutes = _minuts;
OnSelectedHour = hourAction;
OnSelectedMinute = minuteAction;
}
public override string GetTitle(UIPickerView pickerView, nint row, nint component)
{
if (component == 0)
{
return hours[(int)row];
}
else
{
return minutes[(int)row];
}
}
public override void Selected(UIPickerView pickerView, nint row, nint component)
{
if (component == 0)
{
OnSelectedHour(hours[(int)row]);
}
else
{
OnSelectedMinute(minutes[(int)row]);
}
}
}
PickerViewDateSource:
public class PickerViewDateSource : UIPickerViewDataSource
{
public List<string> hours { get; set; }
public List<string> minutes { get; set; }
public PickerViewDateSource(List<string> hours, List<string> minutes)
{
this.hours = hours;
this.minutes = minutes;
}
public override nint GetComponentCount(UIPickerView pickerView)
{
return 2;
}
public override nint GetRowsInComponent(UIPickerView pickerView, nint component)
{
if (component == 0)
{
return (nint)this.hours.Count;
}
else {
return(nint)this.minutes.Count;
}
}
}
Change your code as follows:
protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
{
base.OnElementChanged(e);
if (Control == null)
{
return;
}
var picker = new CustomPicker();
this.Control.InputView = picker;
}
Related
I am trying to follow the example Line Chart / Binding to Local Data. I want to use a view model as my data source. In the view it expects a static method GetElectricityPrices(). How can I make it work with a non-static method?
Here is the view model:
public class ElectricityPrices
{
public int YearPeriod { set; get; }
public double PriceHousehold { set; get; }
public double PriceIndustry { set; get; }
}
Here is the code that is in the view.
#(Html.ShieldChart(<ProjectName>.Controllers.<NameController>.GetElectricityPrices())
.Name("chart")
.Theme("light")
...
Here is a sample static method in the Controller.
public static ElectricityPrices[] GetElectrictyPrices()
{
ElectricityPrices[] prices =
{
new ElectricityPrices { YearPeriod = 2001, PriceHousehold = 0.164, PriceIndustry = 0.103 },
new ElectricityPrices { YearPeriod = 2002, PriceHousehold = 0.173, PriceIndustry = 0.105 },
new ElectricityPrices { YearPeriod = 2003, PriceHousehold = 0.184, PriceIndustry = 0.112 },
new ElectricityPrices { YearPeriod = 2004, PriceHousehold = 0.167, PriceIndustry = 0.111 },
new ElectricityPrices { YearPeriod = 2005, PriceHousehold = 0.177, PriceIndustry = 0.102 },
new ElectricityPrices { YearPeriod = 2006, PriceHousehold = 0.189, PriceIndustry = 0.099 },
new ElectricityPrices { YearPeriod = 2007, PriceHousehold = 0.18, PriceIndustry = 0.011 },
new ElectricityPrices { YearPeriod = 2008, PriceHousehold = 0.183, PriceIndustry = 0.113 },
new ElectricityPrices { YearPeriod = 2009, PriceHousehold = 0.188, PriceIndustry = 0.117 },
new ElectricityPrices { YearPeriod = 2010, PriceHousehold = 0.16, PriceIndustry = 0.119 },
new ElectricityPrices { YearPeriod = 2011, PriceHousehold = 0.176, PriceIndustry = 0.123 },
new ElectricityPrices { YearPeriod = 2012, PriceHousehold = 0.178, PriceIndustry = 0.117 },
};
return prices;
}
The return type of the GetElectrictyPrices() function is IEnumerable<ElectricityPrices>.
The Html.ShieldChart() constructor can accept an IEnumerable collection of any type, which allows you to make a mapping using the .Data(...) method for each series you define to the chart.
I have the following nodes and relationships defined:
CarMaker and Models
A CarModel is made CarMaker in multiple years, and that is represented as a property of the MADE_IN relationship.
A CarModel is made by one CarMaker only.
A CarMaker can make multiple CarModels in multiple years.
I have defined the following Classes to represent the nodes: CarModel, CarMaker and the relationship MADE_IN
CarModel
#NodeEntity
public class CarModel {
private Long id;
private String name;
#Relationship (type="MADE_IN", direction = Relationship.UNDIRECTED)
private Set<MadeIn> madeIns = new HashSet<MadeIn>();
private Set<String> years = new HashSet<String>();
public CarModel() {
}
public Long getId() {
return id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void addMadeIn(MadeIn madeIn) {
System.out.println ("Found CarMaker: " + madeIn.getCarMaker());
this.madeIns.add(madeIn);
}
private Set<MadeIn> getMadeIn() {
return madeIns;
}
public Set<String> getYears() {
Iterator<MadeIn> itr = madeIns.iterator();
while (itr.hasNext()) {
years.add(((MadeIn) itr.next()).getYear());
}
Set<String> sortedYears = years.stream().collect(Collectors.toCollection(TreeSet::new));
return sortedYears;
}
}
CarMaker
public class CarMaker {
#GraphId private Long id;
private String name;
#Relationship (type="MADE_IN", direction = Relationship.UNDIRECTED)
private Set<CarModel> carModels = new HashSet<>();
public CarMaker() {
}
public Long getId() {
return id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Set<CarModel> getCarModels() {
return carModels;
}
public void setCarModels(CarModel carModel) {
carModels.add(carModel);
}
}
MADE_IN
#RelationshipEntity(type="MADE_IN")
public class MadeIn {
#GraphId private Long relationshipId;
#Property private String year;
#StartNode private CarMaker carMaker;
#EndNode private CarModel carModel;
public MadeIn() {
}
public MadeIn(CarMaker carMaker, CarModel carModel, String year) {
this.carMaker = carMaker;
this.carModel = carModel;
this.year = year;
}
public Long getRelationshipId() {
return relationshipId;
}
public void setCarMaker(CarMaker carMaker) {
this.carMaker = carMaker;
}
public CarMaker getCarMaker() {
return this.getCarMaker();
}
public void setCarModel(CarModel carModel) {
this.carModel = carModel;
}
public CarModel getCarModel() {
return this.getCarModel();
}
public String getYear() {
return year;
}
public void setYear(String year) {
this.year = year;
}
}
When I make a request to retrieve a CarModel, I receive a response with the details of that model and all years when it was manufactured:
{
"id": 260248,
"name": "Ulysse",
"years": [
"1994",
"1995",
"1996",
"1997",
"1998",
"1999",
"2000",
"2001",
"2004",
"2005",
"2006",
"2007",
"2008",
"2009",
"2010",
"2011",
"2012"
]
}
The problem is when I try to request the CarModels made by a CarMaker:
{
"id": 4152072,
"name": "BMW",
"carModels": []
}
I noticed that if I reverse the annotations #StartNode and #EndNode on the MadeIn class I get the information about the CarModels made by a CarMaker, however I will not longer get the information about the years when those models were made.
{
"id": 4152072,
"name": "BMW",
"carModels": [
{
"id": 260852,
"name": "120",
"years": []
},
{
"id": 261430,
"name": "Z18",
"years": []
},
{
"id": 262044,
"name": "L7",
"years": []
},
Any idea on what am I missing, or what I am doing wrong ?
Thanks in advance for any help.
--MD
Hy folks!
First: I've found these posts before start my question here: questions/11344035 - questions/15939944 - questions/9412449 - questions/9162359 - questions/1551263.
Second: none of then solved my problem... :(
Well, this is my first MVC4 project, and i tryed send per $.ajax my data as follows:
var exames = {
"ExameId": "",
"Valor": "",
"CodLab": "",
"Dias": "",
"LayoutId": ""
};
var apoio = {
"ApoioId": "",
"Razao": "",
"Endereco": "",
"Bairro": "",
"Cidade": "",
"Uf": "",
"Cep": "",
"Telefone": "",
"Fax": "",
"Email": "",
"CodLab": "",
"Obs": "",
"Status": "",
"ArqRotina": "",
"ArqApoio": "",
"Senha": "",
"Exames": []
};
apoio.ApoioId = $("#hdApoioId").val();
apoio.Razao = $("#Razao").val();
apoio.Endereco = $("#Endereco").val();
apoio.Bairro = $("#Bairro").val();
apoio.Cidade = $("#Cidade").val();
apoio.Uf = $("#Uf").val();
apoio.Cep = $("#Cep").val();
apoio.Telefone = $("#Telefone").val();
apoio.Fax = $("#Fax").val();
apoio.Email = $("#Email").val();
apoio.CodLab = $("#CodLab").val();
apoio.Obs = $("#Obs").val();
apoio.Status = $("#Status").val();
apoio.ArqRotina = $("#ArquivoRotina").val();
apoio.ArqApoio = $("#ArquivoApoio").val();
apoio.Senha = $("#SenhaLab").val();
var tbody = document.getElementById(idTabExames).tBodies[0];
var numLinhas = tbody.rows.length;
for (var i = 0; i < numLinhas; i++) {
exames.ExameId = tbody.rows[i].cells[0].firstChild.nodeValue.toString();
exames.CodLab = tbody.rows[i].cells[1].firstChild.nodeValue;
exames.Dias = tbody.rows[i].cells[2].firstChild.nodeValue;
exames.Valor = tbody.rows[i].cells[3].firstChild.nodeValue;
exames.LayoutId = tbody.rows[i].cells[4].firstChild.nodeValue;
apoio.Exames.push(exames);
exames = {
"ExameId": "",
"CodLab": "",
"Dias": "",
"Valor": "",
"LayoutId": "",
"ApoioId": ""
};
}
$.ajax({
url: '/ApoioExames/Create',
data: JSON.stringify(apoio),
type: 'POST',
contentType: "application/json",
dataType: 'json',
processData: true,
success: function (result) {
if (result.Success == "1") {
if (console.window) console.log('sucess: '+result);
window.location.href = "/ApoioExames/Index";
}
else {
alert(xhr.status);
alert('Error: ' + xhr.responseText);
}
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
}
});
Applying JSON.stringfy(apoio), I get a return of valid json (verified with http://jsonlint.com) but the apoio.Exames field (only it) is null on my controller. Always!
[HttpPost]
public JsonResult Create(ApoioModel apoio)
{
try
{
if (ModelState.IsValid)
{
if (apoio.Id > 0)
{
var exames = db.DbApoioExames.Where(p => p.ApoioId == apoio.Id);
foreach (ApoioExmModel exm in exames)
db.DbApoioExames.Remove(exm);
foreach (ApoioExmModel exm in exames)
db.DbApoioExames.Add(exm);
db.Entry(apoio).State = EntityState.Modified;
}
else
{
db.DbApoio.Add(apoio);
}
db.SaveChanges();
//If (Sucess== 1) { Salvar/Atualizar } else { Exception }
return Json(new { Success = 1, ApoioId = apoio.Id, ex = "" }, JsonRequestBehavior.AllowGet);
}
}
catch (Exception ex)
{
return Json(new { Success = 0, ex = ex.Message }, JsonRequestBehavior.AllowGet);
}
return Json(new { Success = 0, ex = new Exception("Impossível Salvar").Message }, JsonRequestBehavior.AllowGet);
}
My model ApoioModel and ApoioExmModel are:
[Table(name: "apoio", Schema = "public")]
public class ApoioModel
{
[Key, Column("id", Order = 0)]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
[Column("razao")]
[Display(Name = "Razão Social")]
[DataType(DataType.Html)]
[Required(ErrorMessage = "A razão social deve ser informada")]
public string Razao { get; set; }
[Display(Name = "Endereço")]
[Column("endereco")]
public string Endereco { get; set; }
[Display(Name = "Bairro")]
[Column("bairro")]
public string Bairro { get; set; }
[Display(Name = "Cidade")]
[Column("cidade")]
public string Cidade { get; set; }
[Display(Name = "CEP")]
[Column("cep")]
public string Cep { get; set; }
[Display(Name = "UF")]
[Column("uf")]
[StringLength(2)]
public string Uf { get; set; }
[Display(Name = "Status")]
[Range(0, 1), Column("status")]
public int Status { get; set; }
public virtual ICollection<ApoioExmModel> ApoiosExm { get; set; }
}
Table(name: "apoioexm", Schema = "public")]
public class ApoioExmModel
{
[Key, Column("id")]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int? Id { get; set; }
[Column("exame_id")]
public int ExameId { get; set; }
[Column("apoio_id")]
public int ApoioId { get; set; }
[Column("valor")]
public float Valor { get; set; }
[Column("codlab")]
public string CodLab { get; set; }
[Column("dias")]
public float Dias { get; set; }
[Column("layout_id")]
public int LayoutId { get; set; }
[ForeignKey("ApoioId")]
public virtual ApoioModel Apoios { get; set; }
}
I am trying create a CRUD master/detail. I am using Postgre, not SQL Server, but this is not the problem.
When I am debugging in Chrome, I view the data is transfering ok!
Request U R L : h t t p : / / l o c a l h o s t:9795/ApoioExames/Create
Request Headersview source
Accept:application/json, text/javascript, */*; q=0.01
Content-Type:application/json
Origin:h t t p : / / localhost:9795
Referer: h t t p : / / localhost:9795/ApoioExames/Create
User-Agent:Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31
X-Requested-With:XMLHttpRequest
Request Payload
{Razao:kkkkkkk, Endereco:kkkkkkkkk, Bairro:kkkkkk, Cidade:kkkk, Uf:kk, Cep:12341234,…}
Bairro: "kkkkkk"
Cep: "12341234"
Cidade: "kkkk"
Endereco: "kkkkkkkkk"
Exames: [{ExameId:1252, Valor:1, CodLab:1, Dias:1, LayoutId:1826},…]
0: {ExameId:1252, Valor:1, CodLab:1, Dias:1, LayoutId:1826}
1: {ExameId:1252, CodLab:1, Dias:1, Valor:1, LayoutId:1826, ApoioId:}
Razao: "kkkkkkk"
Uf: "kk"
Someone help me?
Sorry my bad english and the large post!
Thanks!
I have two things in mind.
ApoiosExm should be named Exames or vice-versa
I'm not sure if it can map to a ICollection<ApoioExmModel>. Either way, if you ask me, I would recommend not mapping directly to your entity classes.
DB MetersTree TABLE
id text parentId state
0 root 0 open
1 level 1 1 open
2 level 1 1 open
...
CONTROLLER
public ActionResult GetDemoTree()
{
OsosPlus2DbEntities entity = new OsosPlus2DbEntities();
MetersTree meterTree = entity.MetersTree.FirstOrDefault();
return Json(meterTree, JsonRequestBehavior.AllowGet);
}
DATA FORMAT THAT SHOULD BE (for example)
[{
"id": 1,
"text": "Node 1",
"state": "closed",
"children": [{
"id": 11,
"text": "Node 11"
},{
"id": 12,
"text": "Node 12"
}]
},{
"id": 2,
"text": "Node 2",
"state": "closed"
}]
How can I create tree Json Data? If I write MetersTree with its relationships I get the error that is defined in the title.
You need to break the circular reference that is being picked up because of the navigational property in your EF class.
You can map the results into an anonymous type like this, although this is untested:
public ActionResult GetDemoTree()
{
OsosPlus2DbEntities entity = new OsosPlus2DbEntities();
MetersTree meterTree = entity.MetersTree.FirstOrDefault();
var result = from x in meterTree
select new
{
x.id,
x.text,
x.state,
children = x.children.Select({
c => new {
c.id,
c.text
})
};
return Json(result, JsonRequestBehavior.AllowGet);
}
I solved it like this:
VIEW MODEL
public class MetersTreeViewModel
{
public int id { get; set; }
public string text { get; set; }
public string state { get; set; }
public bool #checked { get; set; }
public string attributes { get; set; }
public List<MetersTreeViewModel> children { get; set; }
}
CONTROLLER
public ActionResult GetMetersTree()
{
MetersTree meterTreeFromDb = entity.MetersTree.SingleOrDefault(x => x.sno == 5); //in my db this is the root.
List<MetersTreeViewModel> metersTreeToView = buildTree(meterTreeFromDb.Children).ToList();
return Json(metersTreeToView, JsonRequestBehavior.AllowGet);
}
BuildTree Method
private List<MetersTreeViewModel> BuildTree(IEnumerable<MetersTree> treeFromDb)
{
List<MetersTreeViewModel> metersTreeNodes = new List<MetersTreeViewModel>();
foreach (var node in treeFromDb)
{
if (node.Children.Any())
{
metersTreeNodes.Add(new MetersTreeViewModel
{
id = node.sno,
text = node.Text,
state = node.Text,
children = BuildTree(node.Children)
});
}
else {
metersTreeNodes.Add(new MetersTreeViewModel
{
id = node.sno,
text = node.Text,
state = node.Text
});
}
}
return metersTreeNodes;
}
Thanks to all who are interested in ...
I am struggling to complete a server-client validation solution for a semi-complex scenario. I have a core type called DateRange:
public class DateRange {
public DateRange (DateTime? start, DateTime? end) { ... }
public DateTime? Start { get; private set; }
public DateTime? End { get; private set; }
}
I have a view model like:
public class MyViewModel {
public DateRange Period { get; set; }
}
I have a %mvcproject%\Views\Shared\EditorTemplates\DateRange.cshtml like:
#model MyCore.DateRange
#Html.Editor("Start", "Date")
#Html.Editor("End", "Date")
I also have a DateRangeModelBinder to bind the two form inputs into the DateRange property. The problem I'm having is with a DateRangeRequiredAttribute:
public class DateRangeRequired : ValidationAttribute, IClientValidatable,
IMetadataAware
{
private const string DefaultErrorMessage =
"{0} is required.";
public DateRangeRequired(bool endIsRequired = true)
: base(() => DefaultErrorMessage)
{
EndIsRequired = endIsRequired;
}
public bool EndIsRequired { get; set; }
public override bool IsValid(object value)
{
if (value == null)
{
return false;
}
if (!value.GetType().IsAssignableFrom(typeof(DateRange)))
{
throw new ArgumentException("Value is not a DateRange.");
}
var dateRange = value as DateRange;
return (dateRange.Start.HasValue && !EndIsRequired) ||
(dateRange.Start.HasValue && dateRange.End.HasValue && EndIsRequired);
}
public override string FormatErrorMessage(string name)
{
return string.Format(CultureInfo.CurrentCulture, ErrorMessageString, name);
}
public IEnumerable<ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context)
{
var rule = new ModelClientValidationRule()
{
ErrorMessage = FormatErrorMessage(metadata.GetDisplayName()),
ValidationType = "daterangerequired"
};
rule.ValidationParameters.Add("endisrequired", EndIsRequired.ToString().ToLower());
yield return rule;
}
public void OnMetadataCreated(ModelMetadata metadata)
{
metadata.DataTypeName = "DateRange";
}
}
I can't get it to hook up to the two inputs. It's almost like there needs to be a ValidatorTemplate that pairs with the EditorTemplate because of the split inputs. Any ideas? Let me know if additional clarification is needed.
You haven't shown exactly how your custom DateRangeRequiredAttribute implementation looks like, so let me suggest an example:
public class DateRangeRequiredAttribute : ValidationAttribute, IClientValidatable
{
private readonly string _otherProperty;
public DateRangeRequiredAttribute(string otherProperty)
{
_otherProperty = otherProperty;
}
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
{
var property = validationContext.ObjectType.GetProperty(_otherProperty);
if (property == null)
{
return new ValidationResult(string.Format(CultureInfo.CurrentCulture, "Unknown property {0}", _otherProperty));
}
var otherValue = property.GetValue(validationContext.ObjectInstance, null);
if (!(value is DateTime) || !(otherValue is DateTime))
{
return new ValidationResult(string.Format(CultureInfo.CurrentCulture, "The two properties to compare must be of type DateTime"));
}
if ((DateTime)value >= (DateTime)otherValue)
{
return new ValidationResult(FormatErrorMessage(validationContext.DisplayName));
}
return null;
}
public IEnumerable<ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context)
{
var rule = new ModelClientValidationRule
{
ErrorMessage = FormatErrorMessage(metadata.GetDisplayName()),
ValidationType = "daterange"
};
rule.ValidationParameters.Add("other", "*." + _otherProperty);
yield return rule;
}
}
then you could decorate your view model with it:
public class DateRange
{
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:d}")]
[DateRangeRequired("End", ErrorMessage = "Please select a start date before the end date")]
public DateTime? Start { get; set; }
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:d}")]
[Required]
public DateTime? End { get; set; }
}
and finally in the view register the adapter:
jQuery.validator.unobtrusive.adapters.add(
'daterange', ['other'], function (options) {
var getModelPrefix = function (fieldName) {
return fieldName.substr(0, fieldName.lastIndexOf(".") + 1);
};
var appendModelPrefix = function (value, prefix) {
if (value.indexOf('*.') === 0) {
value = value.replace('*.', prefix);
}
return value;
};
var prefix = getModelPrefix(options.element.name),
other = options.params.other,
fullOtherName = appendModelPrefix(other, prefix),
element = $(options.form).find(':input[name="' + fullOtherName + '"]')[0];
options.rules['daterange'] = element;
if (options.message) {
options.messages['daterange'] = options.message;
}
}
);
jQuery.validator.addMethod('daterange', function (value, element, params) {
// TODO: some more advanced date checking could be applied here
// currently it uses the current browser culture setting to perform
// the parsing. If you needed to use the server side culture, this code
// could be adapted respectively
var date = new Date(value);
var otherDate = new Date($(params).val());
return date < otherDate;
}, '');
After reading this pornography, you might consider using FluentValidation.NET which renders this extremely simple validation scenario a couple of lines to implement (which is how such simple validation scenarios should be done). I would strongly recommend you this library. I am using it in all my projects because I am sick of DataAnnotations for validation. They are so pretty limited.