Pweb 3 Javascript
Nama : Rendi Dwi Francisko
NRP : 5025201056
Kelas : PWEB BTahun : 2022
Contoh implementasi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<link rel="stylesheet" href="assets/style.css"> | |
<title>Document</title> | |
</head> | |
<body> | |
<section class="form"> | |
<form onsubmit="submit_form()"> | |
<h4>Username</h4> | |
<input type="text" placeholder="enter your email id"/> | |
<h4>Password</h4> | |
<input type="password" placeholder="enter your password"/> | |
<input type="submit" value="login"/> | |
<input type="button" value="Signup" onclick="create()"/> | |
</form> | |
</section> | |
</body> | |
<script src="assets/main.js"></script> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function submit_form(){ | |
alert("login Successfully") | |
} | |
function create(){ | |
window.location = "signup.html" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Signup Page</title> | |
</head> | |
<body> | |
<h1>CREATE YOUR ACCOUNT</h1> | |
<table cellspacing="2"> | |
<tr> | |
<td>Name</td> | |
<td><input type="text" placeholder="enter your name" id="n1"></td> | |
</tr> | |
<tr> | |
<td>Email</td> | |
<td><input type="text" placeholder="enter your email" id="e1"></td> | |
</tr> | |
<tr> | |
<td>Set Password</td> | |
<td><input type="password" placeholder="Set a password" id="p1"></td> | |
</tr> | |
<tr> | |
<td>Confirm password</td> | |
<td><input type="password" placeholder="Confirm your password" id="p2"></td> | |
</tr> | |
<tr> | |
<td>Name</td> | |
<td><input type="submit" value="create" onclick="create_account()"></td> | |
</tr> | |
</table> | |
<script type="text/javascript"> | |
function create_account() { | |
var n = document.getElementById("n1").value; | |
var e = document.getElementById("e1").value; | |
var p = document.getElementById("p1").value; | |
var cp = document.getElementById("p2").value; | |
var letters = /^[A-Za-z]+$/; | |
var email_val = /^[a-zA-Z0-9_\.\-]+\@([a-zA-Z0-9\-]+([a-zA-Z0-9](2,4)))+$/; | |
if(n==''||e==''||p==''||cp==''){ | |
alert("enter each detail correctly"); | |
}else if(!letters.test(n)){ | |
alert("name is incorrect must contain alphabets only"); | |
} | |
else if(!email_val.test(e)){ | |
alert("invalid email format"); | |
} | |
else if(p!=cp){ | |
alert("password not macthing") | |
} | |
else if(document.getElementById("p1").value.length > 12){ | |
alert("password maximum length 12") | |
} | |
else if(document.getElementById("p1").value.length < 6){ | |
alert("password minimum length is 6") | |
} | |
else{ | |
alert("account created") | |
window.location="http://google.com" | |
} | |
} | |
</script> | |
</body> | |
</html> |
Komentar
Posting Komentar