Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
DMD3475/week-8/form.html
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
91 lines (75 sloc)
2.31 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Website Contact Form</title> | |
</head> | |
<body> | |
<form method="post" id="myForm" name="myForm"> | |
<h1>Website Contact Form</h1> | |
<p>Required fields are followed by <strong><abbr title="required">*</abbr></strong>.</p> | |
<section> | |
<h2>Contact information</h2> | |
<p> | |
<label for="name"> | |
<span>Name: </span> | |
<strong><abbr title="required">*</abbr></strong> | |
</label> | |
<input type="text" id="name" name="user"> | |
</p> | |
<p> | |
<label for="mail"> | |
<span>E-mail: </span> | |
<strong><abbr title="required">*</abbr></strong> | |
</label> | |
<input type="email" id="mail" name="usermail"> | |
</p> | |
<p> | |
<label for="sbj"> | |
<span>Subject:</span> | |
<strong><abbr title="required">*</abbr></strong> | |
</label> | |
<input type="subject" id="msg" name="subject"> | |
</p> | |
<label for="msg"> | |
<span>Message: </span> | |
<strong><abbr title="required">*</abbr></strong> | |
</label> | |
<input type="message" id="msg" name="message"> | |
</p> | |
</section> | |
<section> | |
<button><a href="#" id="Submit" onclick="myfunction"()>Submit</a></button> | |
</section> | |
</form> | |
<script> | |
//btnSubmit.addEventListener('click', () => { | |
function myfunction(){ | |
if (document.myform.user.value== ""){ | |
alert("Please fill out your name"); | |
document.myForm.user.focus(); | |
return false; | |
} | |
if(document.myform.usermail.value=="") { | |
alert("enter email"); | |
document.myForm.usermail.focus(); | |
return false; | |
} | |
if(document.myform.subject.value=="") { | |
alert("enter subject"); | |
document.myForm.subject.focus(); | |
return false; | |
} | |
if(document.myform.message.value=="") { | |
alert("enter message"); | |
document.myForm.message.focus(); | |
return false; | |
} | |
else{ | |
alert("submit form"); return true; | |
} | |
} | |
//document.getElementById("myForm").submit(); | |
</script> | |
</body> | |
</html> |