Reputation: 16966
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
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