Help validating multiple text fields with error messages

Help validating multiple text fields with error messages

I am very new to JQuery. I am trying to create a basic form where the user will: type a name, enter comments in a textbox, click a radio button, click a check box. If the user does not do one or more of these things, I need an error message to appear besides the box or button on the particular area that is missing. I have everything working for the user name. I don't know how to work in that I need validation on all the other fields. I have tried adding another function below the first one, or adding names separated by a comma in the first function. Anything I have tried so far has made the page dysfunctional. Thanks for taking a look.

  1. <html>
  2.   <head>
  3.     <title>Basic Validation</title>
  4.     <script src="http://code.jquery.com/jquery-latest.js">
  5.     </script>
  6.   
  7.     <script>
  8.       $(function(){
  9.         $('#theButton')
  10.           .click(function(event) {
  11.  if ($("#userName").val()==""){
  12.  alert("empty!");
  13. $("#errUserName").text("Needs a user name!").removeClass("hideError").addClass("showError");

  14.  }else{
  15.  $("#errUserName").text("").removeClass("showError");
  16.  }
  17.           });
  18.       });
  19. </script>

  20. <style>
  21. .showError{
  22. display:block;
  23. color:#ff0000;
  24. }
  25. .hideError{
  26. display:none;
  27. color:#ff0000;
  28. }

  29. </style>
  30.   </head>

  31.   <body>
  32.   <form>
  33.     <label>User Name:</label><BR>
  34. <input type="text" id="userName" /><span id="errUserName" class="hideError">dsa</span>
  35. <br>Tell us about yourself.<br>
  36. <textarea name="comments" cols="25" rows="5"></textarea>    

  37.     

  38.     <div id="jobLike"><br>
  39.     Do you like your job?<BR>
  40.     Yes<input type="radio" name="answerYes" value="1" /> 
  41.     No<input type="radio" name="answerNo" value="2" /> 
  42. <p>
  43. Why?
  44. <br>
  45. <input type="checkbox" name="thePay" />Pay<br>
  46. <input type="checkbox" name="theBenefits" />Benefits<br>
  47. <input type="checkbox" name="theFlexibility" />Flexibility<br>
  48. <input type="checkbox" name="hateJob" />None, I hate it!<br>

  49. <p>
  50.     <input type="button" id="theButton" value="Validate!" />
  51.     </form>
  52.   </body>

  53. </html>