html - I can't get my JavaScript Function to work in Explorer -


i having trouble getting javascript function work in internet explorer. works in browsers other explorer.

the user clicks on button, calls function checks see if password correct. if correct takes user "members page" if incorrect tells user password incorrect

<script>     function myfunction2() {         if (passwordtextbox2.value == "!2008buzzer1") {             location.href = '/jnhsdhdm3gdoeffdut68hjhu.aspx'         } else {             document.getelementbyid("errorlocation").innerhtml = "your password incorrect";         }     } </script> <input type="text" name="passwordtextbox2" id="passwordtextbox2"> <input type="button" onclick="myfunction2()" value='submit'> <p style="color: red" id="errorlocation"></p> 

you should avoid referencing elements name / id directly, it's non-standard feature.

instead use document.getelementbyid(), , other .get*, & .query* methods exclusively.

you should know storing password in javascript offers no real security. javascript runs on client's machine - has access page can see password.

function myfunction2() {    var password = document.getelementbyid('passwordtextbox2'),        error = document.getelementbyid("errorlocation");    if (password.value == "!2008buzzer1") {      location.href = '/jnhsdhdm3gdoeffdut68hjhu.aspx';    } else {      error.innerhtml = "your password incorrect";    }  }
<input type="text" name="passwordtextbox2" id="passwordtextbox2">  <input type="button" onclick="myfunction2()" value='submit'>  <p style="color: red" id="errorlocation"></p>


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -