• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 234
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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