TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Praveen Kumar
NA
235
22.5k
Dev extreme Date Format Validation Problem
Apr 27 2020 9:19 AM
Edit.cshtml
<div class="form-group">
@Html.LabelFor(model => model.StartDate, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@(Html.DevExtreme().DateBoxFor(m => m.StartDate)
.ID("startDate")
.DisplayFormat(System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern)
.Placeholder(System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern)
.ShowClearButton(true)
.InvalidDateMessage("The date must have the following format: " + System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern))
@Html.ValidationMessageFor(m => m.StartDate, null, new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.EndDate, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@(Html.DevExtreme().DateBoxFor(m => m.EndDate)
.ID("endDate")
.DisplayFormat(System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern)
.Placeholder(System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern)
.ShowClearButton(true)
.InvalidDateMessage("The date must have the following format: " + System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern)
.OnValueChanged("endDateChange"))
<span class="text-danger field-validation-error" data-valmsg-replace="true">
<span id="spanEndDate"></span>
</span>
</div>
</div>
Model
[DisplayName("Start date")]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}", ApplyFormatInEditMode = true)]
[Required(ErrorMessage = "Start date is required")]
public DateTime? StartDate { get; set; }
[DisplayName("End date")]
[DisplayFormat(DataFormatString = "{0:d}", ApplyFormatInEditMode = true)]
public DateTime? EndDate { get; set; }
Reply
Answers (
1
)
replacing if with swtich
Upload and download video