I have been using kendo Ui in mvc 3.0 and I am pretty comfortable with that. Recently, I switched in MVC 4 and the main problem I found in this is I am unable to validate kendo controls using MVC model validations(Data Annotations). Please help me regarding validating Kendo Date picker by java script or by model based Validations.I do not want to use kendo validators.I am basically trying to validate like this.
Code
In model:
[Required] //and others bla bla
public string Date {get;set;}
In cshtml page:
@(Html.Kendo().DatePicker()
.Name("datepicker")
.Value("10/10/2011")
.HtmlAttributes(new { style = "width:150px" })
)
@Html.HiddenFor(m => m.Date);
Now at the submit click, I will assign value to hidden field:
OnSaveClick()
{
document.getelementbyId('Date ').value=$("#datepicker).val();
}
Value of datepicker will automatically assign to hidden field and if date picker is empty, then validation on hidden field will fire.
This concepts work in MVC 3.0 but not in MVC 4.0. Please help me. Thanks for paying attention.
$("#datepicker").val()
. Note that you missed a double quote in there. – JohnDubya Jul 22 '13 at 23:07