• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 228
  • Last Modified:

how can I clean all inputs wiht Jquery?

Hello Guys,

I have a form with almost 30 inputs, I have a button that I want to trigger a function where can clean all the inputs.


how can I do this ?

Thanks
0
hidrau
Asked:
hidrau
1 Solution
 
Robin HallSenior Web Solutions ArchitectCommented:
Hidrau,

I'm not sure how you have your form set up but this is a way to do it.  In the fiddle, you can see how I've cleared all the inputs using jquery.  Clear Fields Fiddle

The heavy lifter is this bit of code:

function clearForm($form) {
    $form.find('input:text, input:password, input:file, select').val('');
    $form.find('input:radio, input:checkbox').removeAttr('checked').removeAttr('selected');
}

That you call on your button click and pass it the ID of your Form area.
0
 
BuggyCoderCommented:
I would simply do this:-
$(':input').val('');

Open in new window

0
 
hidrauAuthor Commented:
thanks very much
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now