简体   繁体   中英

javascript error 'email' is not defined.[no-undef]

javascript error 'email' is not defined.[no-undef]

 function confirmInput() { email = document.forms[0].email.value; alert("Hello " + email + "; You are now subscribet to our page"); }
 <form onsubmit="confirmInput()" action="php/email.php" class="offer-form" method="post" name="validate"> <input id="email" type="text" class="txtb" name="email" placeholder="Enter Your Email" required> <input type="submit" class="sub" value="Submit">

Your variable email is not defined. This mean you should add var before email.

var email = document.forms[0].elements.namedItem("email").value;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM