Question
I have to create a new web page file, called validation.html. I need help completing the requirments. Here is my code so far: Validation Home
I have to create a new web page file, called validation.html. I need help completing the requirments. Here is my code so far:
Home Page
function validate() {
uname = document.getElementById('name').value;
pass = document.getElementById('pass').value;
if (uname == "" && pass == "") {
alert("Username and Password required");
}
else if (uname == "") {
alert("Username required");
}
else if (pass == "") {
alert("Password required");
}
else {
alert("Welcome user");
}
}
function bgcolor(col) {
switch (col) {
case 'red':
document.bgColor = "Tomato";
break;
case 'green':
document.bgColor = "MediumSeaGreen";
break;
case 'blue':
document.bgColor = "DodgerBlue";
break;
case 'yellow':
document.bgColor = "yellow";
break;
case 'black':
document.bgColor = "black";
break;
case 'white':
document.bgColor = "white";
break;
}
}
Assignment Requirements
This assignment will use JavaScript functions to include the following:
display the current date and time
display a set of radio buttons that allow the user to change the background color and the text color of the web page by clicking on the desired radio button
advise the user filling out your form with a sentence above the form noting that certain fields are required and using CSS to either make those fields red or placing a CSS styled bold red asterisk (*) next to each required field
validate the form fields according to these validation rules: pops up a JavaScript alert window advising the user exactly what field did not pass the validation checks
First Name and Last Name are not empty
Zip Code is either: only 5 or 9 numbers or in the format 99999-9999
Phone Number is either:
only 10 numbers or in the format (999) 999-9999
Email has one and only one @ character, has at least one character before the @ character, and has at least one character and a period and at least 2 characters after the @ sign. valid: gerland@buffalo.edu not valid: gerland.buffalo.edu not valid: gerland@buffaloedu not valid: @buffalo.edu
places the cursor back in the invalid field after the user clicks the OK button on the alert window,using the .focus() JavaScript method, if there is a validation problem.
add the novalidate attribute to the
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