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
- if(d=='under'){
- $("#usernamemessage").html("Username not long enough");
- }
But don't know how to implement it into the exsisting code.
Thanks
- <input type="text" id="txtusername">
- <input type="button" id="button" onclick="buttonFunction()">
- <span id="usernamemessage"></span>
- <script>
- $(document).ready(function(){
- v=$("#txtusername");
- s=$("#button");
- s.bind('click',function(){
- $.post('check.php',{user:v.val().toLowerCase()},function(d){
- if(d=='available'){
- $("#usernamemessage").html("<span style='color:green;'>Username is available</span>");
- }else{
- $("#usernamemessage").html("<span style='color:red;'>Username is not available</span>");
- }
- });
- });