Nama: Hania Maghfira
NRP: 5115100042
Source code:
<html>
<head>
<title>Registration Form</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://www.w3schools.com/lib/w3.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Raleway">
<link rel="icon" type="image/gif" href="http://www.eyp74.com/imagenes/logo-form.gif">
<style>
body {font-family: "Raleway"; font-size: 12px;
}
</style>
<script type="text/javascript">
function valregister(){
var x=register.txtusername.value;
var x1=parseInt(x);
if(register.txtusername.value==""){
alert("Nama masih kosong");
register.txtusername.focus();
return false;
}
if(isNaN(x1)==false){
alert("Nama harus huruf");
register.txtusername.focus();
return false;
}
var y=register.txtnim.value;
var panjang=y.length;
if(register.txtnim.value==""){
alert("NIM masih kosong");
register.txtnim.focus();
return false;
}
if(panjang<10 || panjang>10){
alert("NIM harus 10 karakter");
register.txtnim.focus();
return false;
}
var z=register.txtmatkul.value;
if(z==""){
alert("NIM masih kosong");
register.txtnim.focus();
return false;
}
var a=register.txtdosen.value;
if(a==""){
alert("Dosen masih kosong");
register.txtdosen.focus();
return false;
}
return true;
}
</script>
</head>
<body>
<div class="w3-container" style="background-color: #2E2E2E">
<h1 class="w3-center" style="margin-top: 64px; color: #FFFFFF; letter-spacing: 7px">REGISTRATION FORM</h1>
<hr>
</div>
<form name="register" action="" method="post" enctype="multipart/form-data" onSubmit="return valregister()">
<table align="center" width="364" border="0" style="margin-top: 128px">
<tr>
<td width="113">Nama</td>
<td width="241">
<label>
<input name="txtusername" type="text" id="txtusername" list="daftarnama">
<datalist id="daftarnama"></datalist>
<script>
var nama = ["Hania Maghfira", "M Satrio Ramadhana Y", "Irfun Hanif", "Panji", "Yuga Mitra Hakiki", "Lee Yong Dae", "Rio Haryanto", "Syamsir Alam"];
var option = '';
for(var m=0; m<nama.length; m++){
option += '<option value="'+nama[m]+'">';
}
document.getElementById('daftarnama').innerHTML = option;
console.log(option);
</script>
</label>
</td>
</tr>
<tr>
<td height="32">NIM</td>
<td>
<label>
<input type="text" name="txtnim" id="txtnim" maxlength="10" list="daftarnim"></td>
<datalist id="daftarnim"></datalist>
<script>
var nim = ["5115100042", "5112100217", "5114100177", "5115100706", "5114100075", "5113100097"];
var option = '';
for(var n=0; n<nim.length; n++){
option += '<option value="'+nim[n]+'">';
}
document.getElementById('daftarnim').innerHTML = option;
console.log(option);
</script>
</label>
</tr>
<tr>
<td height="32">Mata Kuliah</td>
<td>
<label>
<input name="txtmatkul" type="text" id="txtmatkul" list="daftarmatkul">
<datalist id="daftarmatkul"></datalist>
<script>
var matkul = ["Jaringan Komputer", "Kecerdasan Buatan","Manajemen Basis Data","Otomata","Pemrograman Web","Perancangan Analisis Algoritma II"];
var option = '';
for(var k=0; k<matkul.length; k++){
option += '<option value="'+matkul[k]+'">';
}
document.getElementById('daftarmatkul').innerHTML = option;
console.log(option);
</script>
</label>
</td>
</tr>
<tr>
<td height="32">Dosen</td>
<td>
<label>
<input name="txtdosen" type="text" id="txtdosen" list="daftardosen">
<datalist id="daftardosen"></datalist>
<script>
var dosen = ["Abdul Munif", "Bilqis Amaliah", "Chastine Fatichah", "Fajar Baskoro", "Hening TC", "M. Husni", "Rizky Januar", "Sarwosri", "Tohari Ahmad", "Victor"];
var option = '';
for(var l=0; l<dosen.length; l++){
option += '<option value="'+dosen[l]+'">';
}
document.getElementById('daftardosen').innerHTML = option;
console.log(option);
</script>
</label>
</td>
</tr>
<tr>
<td>
<input name="save" type="submit" id="save" value="Submit">
</td>
</tr>
</table>
</form>
<div class="w3-container" style="background-color: #FFFFFF; margin-top: 128px">
<hr>
<p class="w3-center w3-bar" style="color: #000000; letter-spacing: 7px">THANKS</p>
</div>
</body>
</html>
Tampilan source code |
0 Comment:
Posting Komentar