I am trying to setup a registration form by using javascript to confirm if the user typed something into each input field. Right now, If I click the submit button, nothing happens :(.
<form name="registration" id="registration">
<label class="registration-spacing">
<input id="first-name-registration" type="text" name="first-name-registration" placeholder="First Name" size="35">
</label>
<label class="registration-spacing">
<input id="last-name-registration" type="text" name="last-name-registration" placeholder="Last Name" size="35">
</label>
<label class="registration-spacing">
<input id="date-of-birth-registration" type="text" name="date-of-birth-registration" placeholder="Date of Birth" size="35">
</label>
<label class="registration-spacing">
<input id="email-registration" type="text" name="email-registration" placeholder="Email" size="35">
</label>
<label class="registration-spacing">
<input id="username-registration" type="text" name="username-registration" placeholder="Username" size="35">
</label>
<label class="registration-spacing">
<input id="password-registration" type="password" name="password-registration" placeholder="Password" size="35">
</label>
<label class="registration-spacing">
<button type="button" id="submit-registration" onclick="registrationValidation()">Submit</button>
</label>
</form>
function registrationValidation() {
var fName = document.forms["vaidation"].first-name-registration.value;
var lName = document.forms["validation"].last-name-registration.value;
var dob = document.forms["validation"].date-of-birth-registration.value;
var email = document.forms["validation"].email-registration.value;
var username = document.forms["validation"].username-registration.value;
var password = document.forms["validation"].password-registration.value;
if(fName == "" || lName == "" || dob == "" || email == "" || username == "" || password == "") {
alert("Please fill out all required fields.");
return false;
} else {
window.location = "file:///E:/Program Files/eclipse/Workspace/Overrated/WEB-INF/homepage.html";
alert("Registration Successful!");
}
}
vaidation!==validation!==registration? Also, hyphen is not allowed character in property names without bracket notation.