user3496349
user3496349

Reputation: 189

Accessing Input Text Box Value Inside a JavaScript Function

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.

Upvotes: 0

Views: 935

Answers (1)

Popnoodles
Popnoodles

Reputation: 28419

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>

Upvotes: 2

Related Questions