Clearing text fields

Clearing text fields

Hey guys,


I am using jQuery AJAX to submit a form. When the data has been validated successfully and processed, I want to clear the form, but I am unsure how. I have been trying to make it work for a few hours now. I am showing status messages in the container below:

<div id="resultContainer"></div>

When everything was successful, it looks like this:

  1. <div id="resultContainer">
  2.       <div class="success" id="complete">Your registration was successful! However, you must       activate your account before you can login. To do so, please check your e-mail address for       further instructions.</div>
  3. </div>

And here is the simple code I use to clear the text fields:


  1. $('#usnam').val('');
  2. $('#pwd').val('');
  3. $('#pwdrep').val('');
  4. $('#mai').val('');

What I need is a way to check if everything was successful and if so, then run the code above. I tried to do it in a few ways, but it kept clearing regardless of the status.

Any ideas?

Thanks,
Andy