Call function when button on click
Hi everyone, Now I writing some JS codes and I've some issues. I create a text box and button in html as follow: <input id="txtuname" type="text" name="uname" class="txtbox" /> <input name="btnLogin" type="button" class="btn" value="Login" onclick="chkblank" /> I would like to alert messages by clicking button when the text box is empty text. So, I wrote follow scripts but it not working. <script type="text/javascript"> function chkblank(){ var bc=document.getElementsByName("uname"); if (bc.value==""){ alert("Username is blank"); }; } </script> Could you please help with some ideas for me? Thanks. Ko Dway