0

In my code I am trying to acsess a input text box value while inside an external Javascript function. However, I cannot seem to get the code to work. Could someone take a look at this code and determine what I'm doing wrong.

EDIT: PROBLEM HAS BEEN SOLVED. IF ANYONE WANTS TO KNOW HOW TO ACSESS AN ELEMENT FROM A TEXT FIELD USING JAVASCRIPT FEEL FREE TO USE THIS AS A REFRENCE! Thanks.

Html Code:

  <body>

       <form action="VerifyRegistration.html" class="login">

           <h1>Sign Up Here</h1>


           /*Input Text Box*/
           <input type="email" input id = "email"  name="email" class="login-input" placeholder="Email Address" 


           <input type="submit" value="Create Account" class="createaccount">


          /*Once this button is pressed it calls a Javascript function
          <p class="login-help"><a href="javascript:FormChecker();">Need Help?</a></p>


          </form>

          </body>
          </html>

Javascript Code:

    <SCRIPT Language="JavaScript">
    <!--//

      function FormChecker(){
          Email = document.getElementById('email').value;
          alert(Email);
      }

    //-->
    </SCRIPT>

Note: These are in the same file and the javascript coe is below the html.

1 Answer 1

2

You're using getElementById('email') but there is no element with ID "email"

<input id="email" type="email" name="email" class="login-input" placeholder="Email Address" autofocus>
Sign up to request clarification or add additional context in comments.

1 Comment

Ahhh, I was looking at the name and I confused this with the ID. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.