Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

membuat validasi form dengan javascript

<!DOCTYPE html>
<html>
<head>
	<title>Membuat Form Validasi dengan Javascript - WWW.MALASNGODING.COM</title>
	<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
	<center><h2>WWW.MALASNGODING.COM</h2></center>
	<div class="login">
		<form action="#" method="POST" onSubmit="validasi()">
			<div>
				<label>Nama Lengkap:</label>
				<input type="text" name="nama" id="nama" />
			</div>
			<div>
				<label>Email:</label>
				<input type="email" name="email" id="email" />
			</div>
			<div>
				<label>Alamat:</label>
				<textarea cols="40" rows="5" name="alamat" id="alamat"></textarea>
			</div>
			<div>
				<input type="submit" value="Daftar" class="tombol">
			</div>
		</form>
	</div>
</body>
<script type="text/javascript">
	function validasi() {
		var nama = document.getElementById("nama").value;
		var email = document.getElementById("email").value;
		var alamat = document.getElementById("alamat").value;
		if (nama != "" && email!="" && alamat !="") {
			return true;
		}else{
			alert('Anda harus mengisi data dengan lengkap !');
		}
	}
</script>
</html>
Comment

PREVIOUS NEXT
Code Example
Javascript :: condition rendering using if-else 
Javascript :: javascript change IFormFile to base64string 
Javascript :: how to target a hidden html element by js 
Javascript :: white space below image next image 
Javascript :: moment js with nodejs 
Javascript :: nodelist example 
Javascript :: check if value is a string javascript 
Javascript :: expected a string (for built-in components) or a class/function (for composite components) but got: undefined 
Javascript :: async await js 
Javascript :: javascript in jsx 
Javascript :: class declaration in javascript 
Javascript :: map method 
Javascript :: javascript interview questions 
Javascript :: google places API details JS 
Javascript :: switch case 
Javascript :: constructer 
Javascript :: vanilla js 
Javascript :: postgres json 
Javascript :: react native activity 
Javascript :: object.assign 
Javascript :: react native generate signed apk getting older version 
Javascript :: working of a recursive function 
Javascript :: moment isbetween 
Javascript :: javascript save multiple images to server 
Javascript :: maximum number of an array 
Javascript :: add role command discord.js 
Javascript :: Extension Google Chrome Create.. 
Javascript :: row append and calculation in jquery datatable 
Javascript :: insertbefore javascript 
Javascript :: got back to start of for loop js 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =