Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please complete TO DO: requests. Thank you:)! PS: This is basically DOM Event Registration in Javascipt //TO DO: add a parameter to this function to
Please complete "TO DO:" requests. Thank you:)! PS: This is basically DOM Event Registration in Javascipt //TO DO: add a parameter to this function to receive the event object function SignUpForm(){ var valid=true; var warnings=""; var user_inputs = ""; // TODO: remove this line var email = document.forms.SignUp.email.value; // TODO: Get field values for all form fields from the event object var elements = event.currentTarget; var email = elements[0].value; //Email //Username //Password //Confirm Password //-- validate email -- if (email == null || email == ""){ warnings +="Email is empty. "; valid=false; } else if(email.length > 60){ warnings += "Max length for email is 60 characters. "; valid = false; } //if everything is okay, the form should be submitted. //NOTE: for the following validations, always check to see // if the field exists or is empty first //-- validate Username -- //TO DO: check if username is too long //-- validate password -- //TO DO: check if password is exactly 8 characters long //-- Confirm password -- //TO DO: check if password and confirmation match if(valid == false ) { alert(warnings); //prevent form to be submitted if one of above fields is invalid event.preventDefault(); } else{ alert("Signup successful!"); //event.preventDefault(); // should not appear here, but you may add it while //testing to keep the form from resetting. } } // Lab 5 ResetForm Reset Event Handler // // This event handler function should reset the SignUp form to its default state // function ResetForm(){ //TODO: add code to reset the value of SignUp form's text inputs to "" }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started