morpheous
morpheous

Reputation: 16966

jQuery selector question (how to select all input fields on a form EXCEPT buttons and checkbox)

I am trying to select all input fields on a form (except buttons and checkboxes).

I have got as far as to select all the form input elements on a form with id "myform", but I dont know how to exclude buttons and checkbox items. Does anyone know how to do this?

this is what I have so far:

$("#myform :input")

How do I "filter out" buttons and checkboxes on the form?

Upvotes: 38

Views: 23003

Answers (2)

FelipeAls
FelipeAls

Reputation: 22171

You can use :not() combined to :checkbox and :button selectors:

$("#myform :input:not(:button):not(:checkbox)");

and test it with success with the example provided in the documentation of :input

EDIT: :input also selects textarea, select, button and input[type="hidden"] according to documentation (and a useful example)

Upvotes: 11

user434917
user434917

Reputation:

$("#myform :input:not(:checkbox):not(:button)");

Upvotes: 82

Related Questions