jquery validate rule

jquery validate rule

hi guys, I'm having a problem for the code below. the one commented out works fine when i try to leave blank a input box, however when i try to use the one below it is not working. any ideas on how to fix this. I'm new in using jquery. thanks alot


  1. <script>
        $(document).ready(function(){
      <!--      $("#username").rules("add", {required: true, messages: { required: "please enter your name" }});-->
                $("#username").rules("validate"({rules: {field: {required: true, max: 2 } }}));
        });
    </Script>