Pengantar Internet
HTML Dasar
HTML Basic Tag
HTML Dasar (2)
HTML Form
CSS
CSS (2)
Java Script
Java Script (2)
HTML DOM
Materi Praktek Pengantar Internet dan Desain Web tentang Java Script.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
function validasi()
{
var
angka = "0123456789";
var x = 0;
var
nama=document.getElementById('nama').value;
var
email=document.getElementById('email').value;
var
notelp=document.getElementById('notelp').value;
var
website=document.getElementById('website').value;
var
alamat=document.getElementById('alamat').value;
var
komentar=document.getElementById('komentar').value;
if
(nama=="" || email=="" || notelp=="" ||
website=="" || alamat=="" || komentar=="")
{
alert("Ada
form yang belum diisi!");
}
if
(notelp.length!=12)
{
alert("Jumlah karakter no.telepon
salah!");
return
false;
}
if
((email.indexOf('@',0)==-1) || (email.indexOf('.',0)==-1))
{
alert("Format
email salah! Ex: example@example.com");
}
if
((website.indexOf('http://',0)==-1) || (website.indexOf('.',0)==-1))
{
alert("Format
website salah! Ex: http://example.com");
}
for (var i=0; i
< notelp.length; i++)
{
digit
= "" + notelp.substring(i, i+1);
if
(angka.indexOf(digit) == "-1")
{
window.alert("Karakter
no telepon harus angka!!");
return
false;
}
return true;
}
}
</script>
</head>
<body>
<form method="post" onsubmit="return
validasi();">
<center><table width="304"
border="0" bgcolor="#FFFF66">
<tr>
<td
colspan="3"><div align="center"><strong>BUKU
TAMU </strong></div></td>
</tr>
<tr>
<td
width="112">Nama</td>
<td
width="7">:</td>
<td
width="171"><input type="text" name="nama"
id="nama" size="30"/><div
id="valid"></div></td>
</tr>
<tr>
<td>Email</td>
<td>:</td>
<td><input
type="text" name="email" id="email"
size="30"/></td>
</tr>
<tr>
<td>Website</td>
<td>:</td>
<td><input
type="text" name="website" id="website"
size="30"/></td>
</tr>
<tr>
<td>No. Telpon</td>
<td>:</td>
<td><input
type="text" name="notelp" id="notelp"
size="30"/></td>
</tr>
<tr>
<td
valign="top">Alamat</td>
<td
valign="top">: </td>
<td><textarea
cols="22" name="alamat"
id="alamat"></textarea></td>
</tr>
<tr>
<td
valign="top">Komentar</td>
<td
valign="top">: </td>
<td><textarea
cols="22" name="komentar"
id="komentar"></textarea></td>
</tr>
<tr>
<td
colspan="3" align="right"><input type="submit"
name="submit" value="Submit" /></td>
</tr>
</table></center>
</form>
</body>
</html>
0 komentar:
Posting Komentar