Question: function validateForm ( ) { var fullName = document.getElementById ( ' fullName ' ) . value; var dob = document.getElementById ( ' dob ' )

function validateForm(){
var fullName = document.getElementById('fullName').value;
var dob = document.getElementById('dob').value;
var gender = document.getElementById('gender').value;
var email = document.getElementById('email').value;
var phoneNumber = document.getElementById('phoneNumber').value;
var medication = document.getElementById('medication').value;
if (fullName ==""|| dob ==""|| gender ==""|| email ==""
|| phoneNumber ==""|| medication ==""
){
alert("Please fill in all required fields.");
return false;
} else {
// In a real application, here you would handle the form submission,
// such as sending the data to a server. For this example, we'll just log to the console.
console.log("Submitted Data:", { fullName, dob, gender, email, phoneNumber, medication });
alert("Form submitted successfully!");
return true;
}
}
why is my code not returning "form submitted successfully" -- i keep getting the error of cannot read value of null
please fix code so it works properly

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!