Checking multiple input fields...

Checking multiple input fields...

Hello!

I am trying to check couple of text fields if they are filled. But with my code:
If I fill first field I get "All filled!". even if I didn't fill the others..
If I fill all fields except first one I get "All not Filled" which is good!

However, I wanna display "All filled" if all the MustField class fields are filled. What's wrong with my code?

  1. $(document).ready(function() {
  2. $("#submit").click(function() {
  3. if($(".MustField").val().length == 0) {
  4.  alert("All not filled");
  5. }else{
  6. alert("All filled");
  7. return false;
  8. }

  9. });

  10.  <form action="" method="post">
  11. 1:<input type="text" class="MustField"/>
  12. 2:<input type="text" class="MustField"/>
  13. 3:<input type="text" class="MustField"/>
  14. <input type="submit" id="submit" value="submit" />
  15. </form>