I am working on a simple registration form. I'm still working on form validation, but I'm not sure how to work with alerts. The idea is for the user to fill in their information, click on the "Submit" button, and a warning will appear indicating their data. How to add a warning to make this work?
HTML:
<div class="sign-up">
<form>
<h2>Sign Up</h2>
<label>Name:</label>
<input type="text" placeholder="Enter your name" value="" id="suName" required>
<label>Email:</label>
<input type="email" name="email" id="suEmail" required placeholder="Enter a valid email address">
<label>Password:</label>
<input type="password" placeholder="Enter your password" name="password" id="suPassword" required>
<input class="submit-button su-submit" type="submit" id="mySUButton">
</form>
</div>
JS:
function setBindings() {
$(".sign-up form #mySIButton").click(function (e) {
e.preventDefault();
var suName = $(".sign-up form #suName").val(),
email = $(".sign-up form #suEmail").val(),
pw = $(".sign-up form #suPassword").val(),
alert("This is your entered information: " + suName.value + ", " + email.value + ", " + pw + ".");
});
}
$(document).ready(function () {
setBindings();
});
source
share