Hi, amazingly it works! Really thanks a lot for your help...
I got one more question, do you have any idea how I can validate both the datefield to ensure it is a valid Datetime in a specific format? Because even with the datepicker, user can input any string/numbers in the textfield and click submit.. so I want to validate
those manually entered value to ensure it is a DateTime which match the format of my datepicker's Date declared as:
yenni104
Member
363 Points
183 Posts
Re: Custom DateTime Validation for MVC 3 unobtrusive client side validation
Oct 23, 2011 01:06 PM|LINK
Hi, amazingly it works! Really thanks a lot for your help...
I got one more question, do you have any idea how I can validate both the datefield to ensure it is a valid Datetime in a specific format? Because even with the datepicker, user can input any string/numbers in the textfield and click submit.. so I want to validate those manually entered value to ensure it is a DateTime which match the format of my datepicker's Date declared as:
$('#expirydate').datepicker({ constrainInput: true, minDate: 0, dateFormat: 'D, dd M yy' });And one of the datetime form field with the format:
<div class="editor-label"> Expiry Date </div> <div class="editor-field"> @Html.TextBox("ExpiryDate", String.Format("{0:ddd, d MMM yyyy}", DateTime.Now), new { id = "expirydate" }) @Html.ValidationMessageFor(model => model.ExpiryDate) </div>Really thanks a lot for your help!