Tugas 6 JQuery
Nama : M Naufal Badruttamam
NRP : 5025211240
Kelas : Pemrograman Web A
Tahun : 2022 / 2023 (Genap)
Pada pertemuan kali ini, kami diberikan materi seputar framework Javascript, yaitu JQuery, disini kami diberi tugas untuk mengimplementasikan simpel form yang diberikan oleh pak Fajar Baskoro
Result:
Source Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- Jquery -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<!-- style -->
<link rel="stylesheet" href="style.css" />
<title>Document</title>
</head>
<body>
<div id="contact_form">
<form name="contact" action="">
<fieldset>
<div class="input-box">
<label for="name" id="name_label">Name</label>
<input
type="text"
name="name"
id="name"
minlength="3"
placeholder="Monty"
class="text-input"
required
/>
</div>
<div class="input-box">
<label for="email" id="email_label">Email</label>
<input
type="email"
name="email"
id="email"
placeholder="example@tutsplus.com"
class="text-input"
/>
</div>
<div class="input-box">
<label for="phone" id="phone_label">Phone</label>
<input
type="tel"
name="phone"
id="phone"
class="text-input"
placeholder="856-261-9988"
/>
</div>
<input
type="submit"
name="submit"
class="button"
id="submit_btn"
value="Send"
/>
</fieldset>
</form>
<div class="greetings">
<h1>Contact US</h1>
<p>We are waiting to hear from you!</p>
</div>
</div>
<script>
$(function () {
$("form").validate();
});
$(function () {
$("form").on("submit", function (e) {
var dataString = $(this).serialize();
alert(dataString); return false;
$.ajax({
type: "POST",
url: "bin/process.php",
data: dataString,
success: function () {
$("#contact_form").html("<div id='message'></div>");
$("#message")
.html("<h2>Contact Form Submitted!</h2>")
.append("<p>We will be in touch soon.</p>")
.hide()
.fadeIn(1500, function () {
$("#message").append(
"<img id='checkmark' src='images/check.png' />"
);
});
},
});
e.preventDefault();
});
});
</script>
</body>
</html>
* {
box-sizing: border-box;
}
body {
font-family: 'Roboto Slab';
font-size: 1.5rem;
font-weight: 300;
}
div#contact_form {
width: 800px;
display: flex;
align-items: stretch;
justify-content: space-evenly;
border: 2px solid black;
padding: 10px;
}
div.input-box {
display: flex;
margin: 10px 0;
flex-wrap: wrap;
}
div.input-box label {
display: inline-block;
margin: 10px 10px 10px 0;
width: 20%;
}
div.input-box input {
font-size: 1.5rem;
border: 1px solid #ccc;
padding: 4px 8px;
flex: 1;
}
input.button {
font-size: 1.5rem;
background: black;
color: white;
border: 1px solid black;
margin: 10px;
padding: 4px 40px;
}
h1 {
font-size: 5rem;
text-transform: uppercase;
font-family: 'Passion One';
font-weight: 400;
letter-spacing: 2px;
line-height: 0.8;
}
div.greetings {
text-align: center;
font-size: 1.2rem;
background-color: #d3d3d3;
background-image: linear-gradient(15deg, transparent 28%, rgba(255, 255, 255, 0.5) 28%);
background-size: 50px;
}
div.input-box input.error {
border: 2px dashed red;
background: #fee;
}
div.input-box label.error {
color: red;
font-size: 1rem;
text-align: right;
width: 100%;
margin: 10px 0;
}
Komentar
Posting Komentar