title: Form Validation Using Jquery
body: <p>I am using jQuery to validate my form. I would like to see if the username is a single word. I see selector in Jquery <a href="http://jqueryvalidation.org/category/selectors/" rel="nofollow">http://jqueryvalidation.org/category/selectors/</a> but don't know how to use it in my case.</p>
  
  <pre><code>&lt;form id="register" name="register" action="/codejudge/contest.php" method="post" &gt;
  &lt;label for ="Username"&gt; Username &lt;/label&gt;&lt;br&gt;
  &lt;input type="text" class="register-control" id="Username" name="Username"  placeholder="Enter Username"&gt; &lt;br&gt;&lt;br&gt;
  &lt;label for ="Password"&gt; Password &lt;/label&gt;&lt;br&gt;
  &lt;input type="password" class="register-control" id="password" name="password" placeholder="Enter Password" &gt;&lt;br&gt;&lt;br&gt;
  &lt;label for ="Confirm-Password"&gt; Confirm Password &lt;/label&gt;&lt;br&gt;
  &lt;input type="password" class="register-control" id="Confirm_Password" name="Confirm_Password" placeholder="Confirm Password" &gt;&lt;br&gt;&lt;br&gt;
  &lt;label for="email" &gt; Email &lt;/label&gt;&lt;br&gt;
  &lt;input type ="email" class="register-control" id="email" name="email" placeholder="Enter Valid Email"&gt;&lt;br&gt;&lt;br&gt;
  &lt;button type="submit" &gt;Submit&lt;/button&gt;
  
  &lt;/form&gt;
  &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.8/jquery.validate.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  $(document).ready(function(){
  $("#register").validate({
  errorElement: 'div',
  rules:{
      "Username":{
      required: true,     
      minlength:5
      },
  "password":{
  required:true,
  minlength:5
  },
  "Confirm_Password":{
  required:true,
  equalTo: "#password"
  },
  "email":{
  required:true,  
  }
  },
  messages: {
      Username:{
                   required: "Please provide a username",
                  minlength: "Your password must be at least 5 characters long"
      },
       password: {
                  required: "Please provide a password",
                  minlength: "Your password must be at least 5 characters long"
                  },
       Confirm_Password: {
                  required: "Please provide a confirm password",
                  equalTo: "Please enter the same password as above"
                  }
      },
      email:{
                  required: "Please provide a valid email",
      } 
    });  
   });
   &lt;/script&gt;
  </code></pre>