button - JavaScript submit enable on keyup -


my submit button becomes disabled won't go being enabled. what's wrong?

html:

<div class="wrapper">     <form method="post" action="timer.html">         <p><input type="text" name="login" value="" placeholder="username" id='usernamecheck' onkeyup="checkusername()"></p>         <p class="submit"><input type="submit" name="submit" value="login" id="mysubmit"></p>      </form> </div> 

js:

<script>     document.getelementbyid("mysubmit").disabled = true;     function checkusername() {         var usernames = document.getelementbyid("usernamecheck");         if(usernames === 'andrius'){             document.getelementbyid("mysubmit").disabled = false;         }     } </script> 

your code has problems

<input type="text" name="login" value="" placeholder="username"  id='usernamecheck' onkeyup="checkusername()" disabled= "disabled"> 

your js code should this

function checkusername() {     var usernames = document.getelementbyid("usernamecheck").value;     alert(usernames);     if(usernames === 'andrius'){         alert("true");         document.getelementbyid("mysubmit").disabled = false;     } } 

your error did not username field value. returned html object. code work fine you.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -