Question: Question 1: JAVASCRIPT ONLY Fill the validateForm function to check that the phone number is 10 characters long and that the user name is less
Question 1:
JAVASCRIPT ONLY
Fill the validateForm function to check that the phone number is 10 characters long and that the user name is less than 11 characters long. Display "Phone number is invalid" and/or "User name is invalid" in the console log if the check does not pass. Use the preventDefault function to avoid submitting the form when the inputs are invalid.

JavaScript portion:
var form = document.getElementById("userForm");
function validateForm(event) { var phoneNumber = form.phoneNumber.value; var userName = form.userName.value;
/* Your solution goes here */
}
form.addEventListener("submit", validateForm);
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Question 2
Add parentheses to the regular expression to remember the street number (which is: 613) and street name (which is: Amp St), but not remember the apartment number.
var address = "613 Amp St, Apt 57"; // Code will also be tested with "42 Jam St, Apt 3"
var re = /\d+\s\w+\s\w+,\s\w+\s\d+/;
var result = re.exec(address); console.log(result[1] + " " + result[2]);
1 kform d-"userForm" action-"https://learn.zybooks.com" 2 label for-"userName">Username: 3 4 method."POST"> /form
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
