Question: Clear Entries button does not work, please help fix the Java codes. The button is supposed to clear the entries that are being entered. Source
"Clear Entries" button does not work, please help fix the Java codes. The button is supposed to clear the entries that are being entered. Source codes are written below.
Note: The name of the file: survey.html
-------------------
Survey
Please fill in the online survey. Your answer will be stored in a database.
* are required fields.
First Name*:
Last Name*:
Gender*: MaleFemaleOther
Age*:
Grade Level*: Pre-School, 1st Grade, 2nd Grade, 3rd Grade, 4th Grade, 5th Grade, After 5th Grade
Additional Comment:
------------------------
function doSubmit() {
if (validateFirstName() == false) {
alert("Invalid first name. ");
return;
}
if (validateLastName() == false) {
alert("Invalid last name. ");
return;
}
if (validateGender() == false) {
alert("Invalid gender. ");
return;
}
if (validateAge() == false) {
alert("Invalid age. ");
return;
}
if (validateGradeLevel() == false {
alert("Invalid grade level. ");
return;
}
alert("Your survey result had been submitted. ");
return;
}
function validateFirstName() {
var vFirst_Name = document.checking.First_Name.value;
if (vFirst_Name.length == 0) { return false; }
}
function validateLastName() {
var vLast_Name = document.checking.First_Name.value;
if (vLast_Name.length == 0) { return false; }
}
function validateGender() {
var vGender = document.checking.Gender.value;
if (vGender.equalsIgnoreCase("Male") ||
vGender.equalsIgnoreCase("Female") ||
vGender.equalsIgnoreCase("Other") || ) {
return false;
}
}
function validateAge() {
var vAge = document.checking.Age.value;
if (vAge <= 0 || vAge >= 1000) { return false; }
}
function validateGradeLevel {
var vGrade_Level = document.checking.Grade_Level.value;
if (vGrade_Level.equalsIgnoreCase("Pre-School") ||
vGrade_Level.equalsIgnoreCase("1st Grade") ||
vGrade_Level.equalsIgnoreCase("2nd Grade") ||
vGrade_Level.equalsIgnoreCase("3rd Grade") ||
vGrade_Level.equalsIgnoreCase("4th Grade") ||
vGrade_Level.equalsIgnoreCase("5th Grade") ||
vGrade_Level.equalsIgnoreCase("After 5th Grade") || ) {
return false;
}
}
function doClear()
{
document.checking.First_Name.value = "";
document.checking.Last_Name.value = "";
document.checking.getElementById('Gender').innerText = null;
document.checking.Age.value = "";
document.getElementById('Grade_Level').innerText = null;
return;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
