Skip to content

Instantly share code, notes, and snippets.

@bonaxcrimo
Created November 8, 2016 08:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bonaxcrimo/346e945b376617318651167848192c76 to your computer and use it in GitHub Desktop.
Save bonaxcrimo/346e945b376617318651167848192c76 to your computer and use it in GitHub Desktop.
Alert ketika inputbox kosong
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Alert</title>
</head>
<body>
<input type="text" name="" id="nama">
<button onclick="cek()">Kirim</button>
<script type="text/javascript">
function cek(){
var nama=document.getElementById("nama");
if(nama.value.trim() == "")
alert("Tidak boleh kosong");
else
alert("Nama anda "+nama.value);
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment