We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

DatepickerFor Validation

Thread ID:

Created:

Updated:

Platform:

Replies:

118703 Apr 1,2015 11:38 AM UTC Apr 2,2015 12:56 PM UTC ASP.NET MVC 1
loading
Tags: DatePicker
Torbian Linz
Asked On April 1, 2015 11:38 AM UTC

Hi,

in my Form I use Validation with annotations to guide the user. It's client side validation so these flags are set in the webconfig. So I included @Scripts.Render("~/bundles/jqueryval") in my Layout.
I used DatepickerFor to set the Date for some DateTimes of my Viewmodel. I changed the DateFormat but now as soon as the user picks another date, the datepicker is not valid anymore.

Can I somehow get the validation to work?

For your convenience I created an example that generates the exact behavior and is reduced to the core of the problem.

Kind Regards,
Torbian Linz

Attachment: DatePickerForTest_444be4e5.zip

Kasithangam C [Syncfusion]
Replied On April 2, 2015 12:56 PM UTC

Hi Torbian,

We have analyzed your query.The issue ” the user picks another date, the datepicker is not valid anymore” is might have occurred because datatype mismatch while passing the date to the datepicker control.To resolve this issue,please specify the date datatype as string as shown below in model,

<code>

public class DateExample

{

public string dt { get; set; }
}
</code>

Please use the below code to set the value in datepicker control,
<code>

public ActionResult DatePickerFeatures()

{

DatePickerProperties datemodel = new DatePickerProperties();

datemodel.Locale = "en-US";

datemodel.DateFormat = "dd.MM.yyyy";

ViewData["date"] = datemodel;


DateExample d = new DateExample();

d.dt = System.DateTime.Now.ToString();

return View(d);
}
</code>

Also, we have modified your sample based on this and its available under the following location,

Sample: Sample

Please let us know if you need any assistance.
Regards,

Kasithangam


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;