user2664298
user2664298

Reputation: 175

How do find if a control is a listbox using jquery?

I have a dynamic aspx pages where asp.net controls will be enabled and disabled. I am checking what kind of controls are present so that i can validate. i can check wether a controls is a checkbox or radiobutton but how can i check if it is a listbox.

i am trying this but not working any help

  if (control.is('input[type="radio"]')) {
                         alert("radiobuttonlist");
                     }

  if (control.is('input[type="option"]')) {
                         alert("listbox");
                     }

the listbox one is not working how to check if there is a control listbox type

Upvotes: 0

Views: 279

Answers (2)

Eduardo Quintana
Eduardo Quintana

Reputation: 2388

It could be because you're looking for

control.is('input[type="option"]')

Input elements don't have this kind of type.

Maybe you could look for

control.is("option")

Elements

Here you go fiddle

Since you are selecting all the inputs in your $().each because the select is not an input it was not selected by jQuery I changed a little bit the .each() and I evaluated to search it the current object was a select.

Upvotes: 0

COLD TOLD
COLD TOLD

Reputation: 13579

you can try

control.is('select[multiple]')

Upvotes: 1

Related Questions