My validation test

by Julian

HTML

<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/additional-methods.js"></script>

  <form class="" action="" id="edit_profile"  method="post">
<!--Is this OK?-->
              <label>
                Name
              </label>
              <input id="user_name" name="user_name" type="text"  class="form-control input-md"
              >
            
            <div class="form-group">
              <label>
                Role
              </label>
              <input id="role" name="role" type="text"  class="form-control input-md"
             >
            </div>
            <div class="form-group">
              <label>
                Email
              </label>
              <input id="user_email" name="user_email" type="email"
             >
            </div>
            <div class="form-group">
              <label>
                Company Name
              </label>
              <input id="company" class="form-control input-md">
            </div>
          
<input type="hidden" name="user_id" value="<?php echo $_SESSION['user_session'] ?>">
 
 <button type="submit" class="btn btn-small btn-green pull-right" id="submit">

              Save
            </button>
<img src="ajax-loader.gif"  style="float:right" class="loader">
   </form>
<a id="docs" href="http://docs.jquery.com/Plugins/Validation" target="_blank">Validation Documentation</a>

CSS

#docs {
    display: block;
    position: fixed;
    bottom: 0;
    right: 0;
}

JavaScript

$(document).ready(function () {

    $('#edit_profile').validate({ // initialize the plugin
        rules: {
            user_name: {
                required: true,
                minlength: 5
            },
            role: {
                required: true
            },
            user_email: {
                required: true
            },
             company: {
                required: true
            }
        },
        submitHandler: function (form) { 
            alert('valid form submitted');
            return false;
        }
    });
    });