i have an issue with validating datetime textbox,
the datetime is a display date in the following way:
public class Article : TblAbstract<int> {
private DateTime displayDate;
[DisplayName("وقت الظهور")] // Display date in arabic
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:yyyy-MM-dd hh:mm:ss tt}")]
[DataType(DataType.DateTime)]
[Editable(true, AllowInitialValue = true)]
// the error message means: display date is not in a correct format and it must be 2016-09-30 06:26:35 am
[DateTimeFormatValidation(ErrorMessage = "وقت الظهور ليس بالشكل الصحيح، عليك إعتماد هذا الشكل 2016-09-30 06:26:35 am")]
public DateTime DisplayDate {
get { return displayDate; }
set { displayDate = value; }
}
}
public class AddArticleViewsModel : AdminGViewsModel {
private List<ArticleItem> articleItemList;
private Article newArticle;
public AddArticleViewsModel() : base(typeof(AddArticleViewsModel)) {
newArticle = new Article();
newArticle.DisplayDate = DateTime.Now;
articleItemList = new List<ArticleItem>();
}
public List<ArticleItem> ArticleItemList {
get { return articleItemList; }
set { articleItemList = value; }
}
public Article NewArticle {
get { return newArticle; }
set { newArticle = value; }
}
}
i'm using this jquery control over the textbox:
jquery-ui-timepicker-addon-1.6.1.js from the website
http://trentrichardson.com/examples/timepicker
the javascript used:
<script>
$("#txtDisplayDate").datetimepicker({
dateFormat: 'yy-mm-dd',
timeFormat: 'hh:mm:ss tt'
});
</script>
the html and razor for the textbox:
<div class="lblMsg">
// arabic means: warning you to fix the following issues
@Html.ValidationSummary(false, "تنبيه، عليك إصلاح الأخطاء التالية:")
</div>
<p>
@Html.LabelFor(model => model.NewArticle.DisplayDate, new { id = "lblDisplayDate", name = "lblDisplayDate", Class = "lblAddArticle", For = "txtDisplayDate" })
@Html.TextBoxFor(model => model.NewArticle.DisplayDate, "{0:yyyy-MM-dd hh:mm:ss tt}", new { id = "txtDisplayDate", name = "txtDisplayDate", Class = "inputAddArticle" })
</p>
This works fine over all browsers except FIREFOX (Firefox 43.04 64-Bit Edition)
see these images:
Image for the designed page having the issue: i.stack.imgur.com/EMLa4.png
Image to show the issue happen in firefox: i.stack.imgur.com/UGKRc.png