<form name="myform" action="javascript.php" onsubmit="return validasi()" method="post">
First name :<input type="text" name="fname">
Last name :<input type="text" name="lname">
umur :<input type="text" name="age">
<input type="submit" nama="ok" value="submit">
</form>
<script language="javascript" type="text/javascript">
function validasi() {
var x = document.forms["myform"]["fname"].value;
var vlname = document.forms["myform"]["lname"].value;
var usia = document.forms["myform"]["age"].value;
if (x == null||x =="") {
alert("nama depan harus diisi");
return false;
}
if (vlname == null||vlname =="") {
alert("nama belakang harus diisi");
return false;
}
if (usia == null||usia =="") {
alert("nama depan harus diisi");
return false;
}
}
</script>
Tidak ada komentar:
Posting Komentar