/ Published in: JavaScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<html> <head> <script language="javascript"> var secret_password = "jasmine"; var entered_password = prompt("please enter password", " "); if (entered_password != secret_password) { document.write("incorrect"); } else { document.write("welcome"); } </script> </head> <body> </body> </html> <html> <head> <script language="javascript"> var secret_password = "jasmine"; var usernmae = "password"; var entered_password = prompt("please enter password", " "); var entered_username = prompt("please enter username", " "); if ((entered_password == secret_password) && (entered_username == username)) { document.write("correct"); } else { document.write("try again"); } </script> </head> <body> </body> </html> <html> <head> <script language="javascript"> var admin = admin var developer = "mike"; var user = "user"; var entered_password = prompt("please enter password", " "); switch (entered_password) { case "admin": alert("you are admin"); break case "mike": alert("you are a developer"); break case "user": alert("you are a user"); break default: alert("password Incorrect!!"); break } </script> </head> <body> </body> </html>