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

[Solved] combo box client validation "on focus out" of the control, using data annotation on models MVC3

7 Answers 88 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.
Narayanarao
Top achievements
Rank 1
Narayanarao asked on 11 Jan 2012, 10:43 AM
Hi telerik team,

i have implemented validation to combobox using unobstrusive client validation ousing data annotations on model, as described here "http://demos.telerik.com/aspnet-mvc/combobox/clientvalidation "

I see that the validation occurs only on form submit. i would want the validation to happen at control out of focus as-well when tabbed say. could you help. I have tried a number of things that i received on google. did not get any solutions for the same.

Thanks,
Anand

7 Answers, 1 is accepted

Sort by
0
Narayanarao
Top achievements
Rank 1
answered on 13 Jan 2012, 08:25 AM
Telerik team,

Any thoughts yet.

The licence entitles me for a 24 Hr turnover for issues, its been more around  2 days now ! please share your thoughts
0
Accepted
Georgi Krustev
Telerik team
answered on 13 Jan 2012, 10:16 AM
Hello Narayanarao,

Telerik does not guarantee replies to forum posts as they are mainly a community driven resource. Please open a support ticket which has 24 hour guarantee response time when you need timely replies from Telerik
staff.

As to the question - the required functionality is not easy achievable, because the jQuery validates only the input corresponding to the name attribute. As you probably know, the combobox has two inputs:
1. for the selected value, that can be validated and subsequently posted
2. for the selected text which is not validated as it is not required. 
After this is said, I believe that you can wire the OnChange event and call validate method of the form.

Regards,
Georgi Krustev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Narayanarao
Top achievements
Rank 1
answered on 13 Jan 2012, 10:36 AM
Thanks Georgi.

Will check the feasiability of the same and getback.

So i am assuming from below suggestion that by default/no direct solution available for a tab out validation. Please correct me if I am mistaken
0
Georgi Krustev
Telerik team
answered on 16 Jan 2012, 09:07 AM
Hello Narayanarao,

 
Unfortunately, there is not direct solution for the required functionality. Let me know if other questions arise.

Regards,
Georgi Krustev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Narayanarao
Top achievements
Rank 1
answered on 18 Jan 2012, 07:40 AM
Hi Georgi,

The above solution works good.  except for that I have  a concern. The combo box implemented by me is a search combobox hence while I type the combo box items appear. if i just type in  entry fast with incomplete string (any  combo box item is  yet to appear to be auto selected) then these fail. any thoughts to take care of this delay.

to elaborate more suppose i have countries "US", "UK", and India say on my combo box along with a first item "--Select--"

then if i just type out "--" fast and tab before the combo box search list is populated the text  remains at "--" with no corresponding item.

Best regards,
Anand
0
Accepted
Georgi Krustev
Telerik team
answered on 19 Jan 2012, 10:09 AM
Hello,

 
Depending on the given information, I believe that you need to prevent entering of a custom value in this combobox. If this is the case, then you can wire the OnChange event and prevent entering of a custom value:

function onClientComboChanged(e) {
    var combo = $(this).data('tComboBox');
    if (combobox.value() && combo.selectedIndex < 0) {
        alert("custom value");
    }
}
Kind regards,
Georgi Krustev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Amit
Top achievements
Rank 1
answered on 31 Mar 2012, 09:02 AM
Hello Narayanarao ,

I need the same functionality that telrik combobox having client side validation i.e. if user focus out from the telrik combo box with default selected item then it should raise error message. Can you give me your solution as you say your issue resolved!

Thanks
Amit Shah
Tags
ComboBox
Asked by
Narayanarao
Top achievements
Rank 1
Answers by
Narayanarao
Top achievements
Rank 1
Georgi Krustev
Telerik team
Amit
Top achievements
Rank 1
Share this question
or