As a newcomer to the world of html and js, I am struggling to incorporate js into my html code. Despite multiple attempts at modification, I have not been successful in getting it to work. Any guidance or advice on this issue would be highly appreciated.
I have experimented with various elements such as input types, actions, if and else if statements, alert functions, and much more.
function validation() {
var name = document.getElementById('Name').value;
var email = document.getElementById('Email').value;
var tel = document.getElementById('Telephone').value;
if (Name == '' || Email == '' || Telephone == '')
alert('action required')
return false;
} else if (name.length < 4) {
alert("action required")
return false;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="utf-8">
<link rel="stylesheet" href="css/WebForm.css">
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>COM111 | WebForm | B0076234</title>
<meta name="viewport" content="width = device-width, inital-scale = 1.0">
<script src="assignment2/ass2script.js"></script>
<h1 id="h1">Welcome To My WebForm</h1>
<h2 id="h2"> CV Request</h2>
</head>
<body>
<!-- form -->
<form action="" method="post" onsubmit="return validation()">
<div class="wrap">
<div class="form1">
<div class="input-fields">
<input type="text" class="input" placeholder="Name" id="name">
<input type="email" class="input" placeholder="Email" id="Email">
<input type="tel" class="input" placeholder="Telephone" id="Telephone">
<input type="text" class="input" placeholder="Company" id="Telephone"><br>
<input type="submit" name="submit" value="Insert now">
<label>Short CV
<input type="radio" checked="checked">
</label> <br>
<label>Long CV
<input type="radio">
</label>
</div>
<div class="message">
<textarea placeholder="Message"></textarea>
<div class="btn">send</div>
</div>
</div>
</div>
</form>
<div id="eresult"></div>
</body>
</html>