Tugas PWEB membuat validasi form
Nama: Arini Indah Nur Fuadah
NRP: 05111740007003
Kelas: C
1. HTML
2. CSS
3. JS
4. Hasilnya:
Langsung cek di beritasaatini.hirin.online
NRP: 05111740007003
Kelas: C
1. HTML
- Daftar
<!DOCTYPE html>
<html>
<head>
<title>Daftar Kuy</title>
<link rel="stylesheet" type="text/css" href="dftr.css">
</head>
<body>
<div class="header">
<h2>Saat.Com</h2>
</div>
<div class="login">
<form method="post" action="#" onsubmit="return validasi_input(this)">
<div>
<label>Nama:</label>
<input name="username" type="text">
</div>
<div>
<label>Email:</label>
<input type="email" name="email" id="email" />
</div>
<div>
<label>Tanggal Lahir:</label>
<input type="date" name="date"/>
</div>
<div>
<label>Jenis Kelamin :</label>
<input type="radio" name="jk" value="L">
<input type="radio" name="jk" value="P">
</div>
<div>
<label>No Telp:</label>
<input name="telepon" type="tel">
</div>
<div>
<label>Password:</label>
<input name="Password" type="Password">
</div>
<div>
<label>Jenis Kesukaan:</label>
<input name="suka" type="text">
</div>
<div>
<input type="submit" value="Daftar" class="tombol">
</div>
</form>
</form>
</div>
<div class="footer">
<p>Copyright 2018 codebareng all reserved</p>
</div>
<script type="text/javascript" src="dftrjs.js"></script>
</body>
</html>
- Masuk
<!DOCTYPE html>
<html>
<head>
<title>Masuk Kok</title>
<link rel="stylesheet" type="text/css" href="msk.css">
</head>
<body>
<div class="header">
<h2>Saat.Com</h2>
</div>
<div class="login">
<form name="myForm" action="#" method="POST" onSubmit="validasi()">
<div>
<label>Nama:</label>
<input type="text" name="fname"required />
</div>
<div>
<label>Email:</label>
<input type="email" name="email" id="email" />
</div>
<div>
<label>Password:</label>
<input type="Password" name="Password"/>
</div>
<div>
<input type="submit" value="Masuk" class="tombol">
<span><a href="_blank">Forgot Password</a></p></span>
</div>
</form>
</form>
</div>
<div class="footer">
<p>Copyright 2018 codebareng all reserved</p>
</div>
</body>
</html>
2. CSS
- Daftar
body{
background: #99FFCC;
color: #333;
width: 100%;
font-family: sans-serif;
margin: 0 auto;
}
.header{
width: 325px;
margin: auto;
height: 50px;
line-height: 50px;
background: #333e33e6;
color: #74C599;
text-align: center;
}
.login {
padding: 10px;
margin: 10px auto;
width: 300px;
background: rgba(255,255,255,0.5);
}
label {
font-size: 10pt;
color: #2e2e2e;
}
input[type="text"],
input[type="email"],
input[type="Password"],
input[type="date"],
input[type="tel"],
textarea {
padding: 8px;
width: 95%;
background: #efefef;
border: 0;
font-size: 10pt;
margin: 6px 0px;
}
.tombol {
background: #3498db;
color: #fff;
border: 0;
padding: 5px 8px;
}
.footer{
width: 325px;
margin: auto;
height: 50px;
line-height: 50px;
color: #fff;
text-align: center;
font-size: 10pt;
}
- Masuk
body{
background: #99FFCC;
color: #333;
width: 100%;
font-family: sans-serif;
margin: 0 auto;
}
.header{
width: 325px;
margin: auto;
height: 50px;
line-height: 50px;
background: #333e33e6;
color: #74C599;
text-align: center;
}
.login {
padding: 10px;
margin: 10px auto;
width: 300px;
background: rgba(255,255,255,0.5);
border-radius: 3px;
}
span{
float: right;
font-size: 9pt;
}
label {
font-size: 10pt;
color: #2e2e2e;
}
input[type="text"],
input[type="email"],
input[type="Password"],
textarea {
padding: 8px;
width: 95%;
background: #efefef;
border: 0;
font-size: 10pt;
margin: 6px 0px;
}
.tombol {
background: #3498db;
color: #fff;
border: 0;
padding: 5px 8px;
}
.footer{
width: 325px;
margin: auto;
height: 50px;
line-height: 50px;
color: #fff;
text-align: center;
font-size: 10pt;
}
- Daftar
function validasi_input(form){
var maxcar = 50;
var mincar = 1;
if (form.username.value.length > maxcar|| form.username.value.lenght < mincar){
alert("Username Tidak Boleh Kosong atau Maksimal 50 Karater!");
form.username.focus();
return (false);
}
return (true);
}
function validasi_input(form){
function check_radio(radio)
{
// memeriksa apakah radio button sudah ada yang dipilih
for (i = 0; i < radio.length; i++)
{
if (radio[i].checked === true)
{
return radio[i].value;
}
}
return false;
}
var radio_val = check_radio(form.jk);
if (radio_val === false)
{
alert("Anda belum memilih Jenis Kelamin!");
return false;
}
return (true);
}
4. Hasilnya:
Langsung cek di beritasaatini.hirin.online
Komentar
Posting Komentar