I am working on a production environment. The issue is the DOB field is provided with mvc model validations and in the view jquery.validate.unobtrusive.js is used to validate the form.
Date picker is used to pick the date, when I submit the form, the ModelState.IsValid fails.
The code is shown below. This works properly with Chrome, but not in other browsers.
In my model:
[Required(ErrorMessage = "Please enter DOB")]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}", ApplyFormatInEditMode = true)]
public Nullable<System.DateTime> DOB { get; set; }
This is my view:
<div class="col-md-6">
<div class="col-xs-12">
<label>DATE OF BIRTH<p>*</p></label>
</div>
<div class="col-xs-12">
<div class="form-group">
<div class="input-group" id="datetimepicker2">
@Html.TextBoxFor(d => d.DOB, new { @class = "form-control input-validation-error" })
<span class="input-group-addon"><span class="icon-small-calendar"></span></span>
</div>
@Html.ValidationMessageFor(m => m.DOB)
</div>
</div>
</div>
This is my datepicker:
$('#datetimepicker2').datetimepicker({
format: 'MM/DD/YYYY',
maxDate: new Date()
});
In my controller:
if (ModelState.IsValid)
{
///some action
}
In my web.config:
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
Can someone help me how to fix this for all browsers
Thanks in advance Tarak