This is a migrated thread and some comments may be shown as answers.

[Solved] validation bug!

1 Answer 108 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
mahmoud
Top achievements
Rank 1
mahmoud asked on 18 Jun 2011, 12:20 PM
Dear telerik developers/users,
I have the following code :
@(Html.Telerik().ComboBoxFor(model => model.ContactId)
        .AutoFill(true)
            .BindTo(((IEnumerable<Contact>)ViewBag.PossibleContacts).Select(option => new SelectListItem
            {
                Text = (option == null ? "(empty") : option.Title),
                Value = option.Id.ToString(),
                Selected = (Model != null && option.Id == Model.ContactId)
            }))
        .HighlightFirstMatch(true)
        .OpenOnFocus(true)
)

@Html.ValidationMessageFor(model => model.ContactId)

the problem is if you enter a number value in  which is not valid and not presents in the related list (for example:937493) the validation passes! (it just checks if the value is number or not which emitted from EF model validation)

1 Answer, 1 is accepted

Sort by
0
Vikas
Top achievements
Rank 1
answered on 18 Aug 2011, 08:44 PM
Hi Telerik Team

I have almost the same problem.

I am using Telerik (2011.2.712) and the jquery validation which comes with the installation and using jquery-1.6.2.min.js for jquery.

 @Html.Telerik().ScriptRegistrar().Scripts(x => x.Add("~/Content/common/js/libs/jquery.validate.min.js")).jQuery(false).OutputScriptFiles(true)


  @Html.Telerik().ComboBoxFor(m => m.Code).AutoFill(true).ClientEvents(events => events.OnChange("onClientComboChanged")).BindTo(new SelectList(new[]
                                          {
                                              new {Value="",DisplayText="Select A Time"},
                                              new {Value="08:00 am",DisplayText="Morning"},
                                              new {Value="12:00 am",DisplayText="Noon"},
                                              new {Value="02:00 pm",DisplayText="Afternoon"},
                                              new {Value="04:00 pm",DisplayText="Early Evening"},
                                              new {Value="06:00 pm",DisplayText="Evening"},
                                              new {Value="01:00 am",DisplayText="1 am"},
                                              new {Value="02:00 am",DisplayText="2 am"},
                                              new {Value="03:00 am",DisplayText="3 am"},
                                              new {Value="04:00 am",DisplayText="4 am"},
                                              new {Value="05:00 am",DisplayText="5 am"},
                                              new {Value="06:00 am",DisplayText="6 am"},
                                              new {Value="07:00 am",DisplayText="7 am"},
                                              new {Value="08:00 am",DisplayText="8 am"},
                                              new {Value="09:00 am",DisplayText="9 am"},
                                              new {Value="10:00 am",DisplayText="10 am"},
                                              new {Value="11:00 am",DisplayText="11 am"},
                                              new {Value="12:00 pm",DisplayText="12 pm"},
                                              new {Value="01:00 pm",DisplayText="1 pm"},
                                              new {Value="02:00 pm",DisplayText="2 pm"},
                                              new {Value="03:00 pm",DisplayText="3 pm"},
                                              new {Value="04:00 pm",DisplayText="4 pm"},
                                              new {Value="05:00 pm",DisplayText="5 pm"},
                                              new {Value="06:00 pm",DisplayText="6 pm"},
                                              new {Value="07:00 pm",DisplayText="7 pm"},
                                              new {Value="08:00 pm",DisplayText="8 pm"},
                                              new {Value="09:00 pm",DisplayText="9 pm"},
                                              new {Value="10:00 pm",DisplayText="10 pm"},
                                              new {Value="11:00 pm",DisplayText="11 pm"},
                                              new {Value="12:00 am",DisplayText="12 am"},
                                              
                                          }, "Value", "DisplayText", 1)).SelectedIndex(0).HtmlAttributes(new Dictionary<string, Object> { { "validate", "required:true" }, { "class", "select" }, { "title", "Please select Time" }, { "id", "Code" } }).Filterable(filtering => filtering.FilterMode(AutoCompleteFilterMode.Contains)).HighlightFirstMatch(true).OpenOnFocus(true)

                                           @Html.ValidationMessageFor(m => m.Code)


Somehow the ComboBox validation is not working. Quick help will be appreciated.
Tags
ComboBox
Asked by
mahmoud
Top achievements
Rank 1
Answers by
Vikas
Top achievements
Rank 1
Share this question
or