<form name = "myform" action = "javascript.php" onsubmit="return validateform()" 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" value = "submit">
</form>
<script language = "javescript" type = "text/javascript">
function validateform(){
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