validating drop down box

+3 eric bruce · August 5, 2014
hello im new to forum been watching a lot of the videos iv finessed the java scripts basics the xhtml/css and am currently on the html5 ones 
anyway iv been playing around with some java script code on my own and i know what the problem is with the code im using im just not really shore how to fix it and was hoping some one would help me out i know why its not working i just don't really know how to fix it 

iv tried to use the match with aptbox but doesn't really work could be im just using it wrong 

know i understand that the aptbox var is really doing anything in this atm but what id  like it to be doing is getting the value of the selected item in the drop down box matching it to a pre made password then just printing out the text thanks and sorry if it looks really bad lol

java script

function checkPass()
{
    //Store the password field objects into variables ...
var password = "123456";
var aptbox = document.getElementById('dropbox');
var pass1 = document.getElementById('pass1');
var message = document.getElementById('confirmMessage');

    if(aptbox.value && pass1.value.match(password)){
        message.innerHTML = "Passwords Match!"
    }else{
        message.innerHTML = "Passwords Do Not Match!"
    }



html

div>
    <form>
<select id="dropbox">
<option id="apt1">apt1</option>
<option id="apt2">apt2</option>
</select>

        <div class="fieldWrapper">
Password:<input type="password" name="pass1" id="pass1" onkeyup="checkPass(); return false;">
            <span id="confirmMessage" class="confirmMessage"></span>
        </div>
    </form>
</div>
      <script src="jsfile.js"></script>

Post a Reply

Replies

Oldest  Newest  Rating
+1 Abdullah Nauman · August 13, 2014
And Llama this is a community of respectable people. Could you please respect US, and TRY to me nice! :angry:
+1 Brandon Elliott · August 13, 2014
I've never seen llama actually help someone with their code, he just bickers about their post and how it wasn't good enough for him lol
  • 1

Javascript

107,075 followers
About

A scripting language that is added to standard HTML to create interactive effects, apps, games for the browser.

Links
Moderators