Help add more 'if' to code

Help add more 'if' to code

Hello

My code checks the username entered in a PHP file. The jQuery then displays if the username is taken or not.

I have added code to the PHP file to also check if the username is below 3 characters or over 16 characters. How do I add another if within this code to display the correct result?

I know the code will be

  1.  if(d=='under'){
  2.     $("#usernamemessage").html("Username not long enough");
  3.    }
But don't know how to implement it into the exsisting code.

Thanks

  1. <input type="text" id="txtusername">
  2. <input type="button" id="button" onclick="buttonFunction()">
  3. <span id="usernamemessage"></span>
  4. <script>
  5. $(document).ready(function(){
  6.  v=$("#txtusername");
  7. s=$("#button");
  8.  s.bind('click',function(){
  9.   $.post('check.php',{user:v.val().toLowerCase()},function(d){
  10.    if(d=='available'){
  11.     $("#usernamemessage").html("<span style='color:green;'>Username is available</span>");
  12.    }else{
  13.     $("#usernamemessage").html("<span style='color:red;'>Username is not available</span>");
  14.    }
  15.   });
  16.  });