Validation form program doesnot working properly

This is the code I write for the validation form program but this program sometimes shows: Failed to load resource: The server responded with a status of 405 ()" and sometimes it does not execute if conditions and go to else if condition.

try better coding practice clean and step by step by debugging step by step what you doing, what code is returning. This way you can make more possible to reduce bugs.

for the above error the Server is rejecting and confused to return after form submitted.
change code like this

onsubmit="return validateForm(event.preventDefault())"

other way to improve coding
instead doing do like
let form = document.getElementById(‘form1’)
let name =

if (name == null || name == " " || name == undefined) // “” instad of " " check difference