javascript - See if text input is there -


so i'm trying check if user has inputed text through textbox userinput. however, when try writing if else statement validate input, nothing seems work. help?

<div class="container"> <div class="row">     <div class="page-header">         <h1 align="center">sub me <small>easily create youtube subscription links!</small></h1>     </div> </div>  <script type="text/javascript">     function showlink() {                    $("#linkbox").css("visibility", "visible");          $("#linktext").html("http://subto.me/"+$("#usernameinput").val())         $("#linkhref").attr("href", "http://subto.me/"+$("#usernameinput").val()) }    </script>  <div class="row">     <div class="span6 offset3">         <div class="form-inline">             <div class="input-append">                 <input class="span4" type="text" id="usernameinput" placeholder="youtube username">                 <button class="btn" onclick="showlink();">get link</button>             </div>         </div>     </div> </div> <div class="row" id="linkbox" style="visibility: hidden; margin-top: 25px;">     <div class="span12">         <div class="alert alert-success" style="width: 50%; margin: 0 auto; text-align: center; padding: 24px;">             <a id="linkhref" href="" target="_blank"><span id="linktext" style="font-size: 24pt; font-weight: bold;"></span></a>         </div>     </div> </div> 

here
thous should stop users submitting blank forms, , dont forget include jquery library.

<script type="text/javascript" src="scripts/jquery-1.9.1.js"></script>     <script type="text/javascript">         function showlink() {             var usernameinput = $('#usernameinput').val();             if(usernameinput != ''){                  $("#linkbox").css("visibility", "visible");                  $("#linktext").html("http://subto.me/"+$("#usernameinput").val())                 $("#linkhref").attr("href", "http://subto.me/"+$("#usernameinput").val())             }             else{                 alert('please enter something');             }     }        </script> <div class="container"> <div class="row">     <div class="page-header">         <h1 align="center">sub me <small>easily create youtube subscription links!</small></h1>     </div> </div> <div class="row">     <div class="span6 offset3">         <div class="form-inline">             <div class="input-append">                 <input class="span4" type="text" id="usernameinput" placeholder="youtube username">                 <button class="btn" onclick="showlink();">get link</button>             </div>         </div>     </div> </div> <div class="row" id="linkbox" style="visibility: hidden; margin-top: 25px;">     <div class="span12">         <div class="alert alert-success" style="width: 50%; margin: 0 auto; text-align: center; padding: 24px;">             <a id="linkhref" href="" target="_blank"><span id="linktext" style="font-size: 24pt; font-weight: bold;"></span></a>         </div>     </div> </div> 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -