Question: the javascript validation doesn't seem to work when I try to run the webpage I tried to do all in one file and I also
the javascript validation doesn't seem to work when I try to run the webpage I tried to do all in one file and I also tried to put in separate files as file.js and the HTML where I tried to call the file by writing this just the java scirot code function validate
var name document.getElementByIdnamevalue;
var email document.getElementByIdemailvalue;
var phoneNumber document.getElementByIdphone number"value;
var password document.getElementByIdpasswordvalue;
var confirmPassword document.getElementByIdconfirm password"value;
var errorMessage document.getElementByIderrormessage";
errorMessage.innerHTML ;
var text;
if namelength
text "Please enter a valid name minimum characters;
errorMessage.classList.adderror;
errorMessage.innerHTML text;
return false;
if validateEmailemail
text "Please enter a valid email address must contain @ and be at least characters;
errorMessage.classList.adderror;
errorMessage.innerHTML text;
return false;
Enforce NumbersOnly Password with Security Warning
if isNaNpassword
text "Password must only contain numbers. WARNING: Using only numbers makes your password significantly weaker and easier to crack. Please consider using a mix of numbers, letters, and symbols for better security.";
errorMessage.classList.adderror;
errorMessage.innerHTML text;
return false;
if confirmPassword password
text "Passwords do not match. Please reenter your password.";
errorMessage.classList.adderror;
errorMessage.innerHTML text;
return false;
console.logForm submitted successfully!";
alertForm submitted successfully!";
return true;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
