Hello,
I need to use Autcomplete and the field associate with it in my model have a Required attribute.
So in my view despite I have a value in the Autocomplete, I got the message "Required field". I keep the @Html.ValidationMessageFor under my @(Html.Telerik().AutoCompleteFor...
How I can keep this validation and avoid "Required field" when I have a value?
Have nice Holidays.
I need to use Autcomplete and the field associate with it in my model have a Required attribute.
So in my view despite I have a value in the Autocomplete, I got the message "Required field". I keep the @Html.ValidationMessageFor under my @(Html.Telerik().AutoCompleteFor...
How I can keep this validation and avoid "Required field" when I have a value?
Have nice Holidays.
4 Answers, 1 is accepted
0
Hi Louis,
Atanas Korchev
the Telerik team
We couldn't understand what the problem is. Is validation working or not? Could you provide some more code? The model and view would be enough.
Regards,Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Louis
Top achievements
Rank 1
Iron
Iron
Iron
answered on 28 Dec 2012, 02:43 PM
This is the code :
In the model :
In the view :
Even I put a value in the autocomplete, the messsage "Field required" display.
In the model :
[Required(ErrorMessageResourceType = typeof(GlobalesResources), ErrorMessageResourceName = "RequiredMessage")]
public string Nom { get; set; }
@(Html.Telerik().AutoCompleteFor(model => model.Nom)
.Name("strNom")
.ClientEvents(events => events
.OnError("Grid_onErrorRequestedURLNotReturnJSON")
)
.Encode(false)
.DataBinding(binding => binding.Ajax().Select("ObtenirIdentifications", "LesNoms"))
)
@Html.ValidationMessageFor(model => model.Nom)
Even I put a value in the autocomplete, the messsage "Field required" display.
0
Accepted
Hello,
Regards,
Atanas Korchev
the Telerik team
Your autocomplete should be named as the property which it represents in order for validation to work as expected. AutoCompleteFor will do this automatically thus there is no need to set the Name of the widget. Try this:
@(Html.Telerik().AutoCompleteFor(model => model.Nom)
.ClientEvents(events => events
.OnError("Grid_onErrorRequestedURLNotReturnJSON")
)
.Encode(false)
.DataBinding(binding => binding.Ajax().Select("ObtenirIdentifications", "LesNoms"))
)
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Louis
Top achievements
Rank 1
Iron
Iron
Iron
answered on 28 Dec 2012, 04:04 PM
It's working #1!!! Thank you Atanas and happy NEW YEAR!!!