WebArtz - The Web Design Forum
Welcome to WebArtz, Guest!

WebArtz is a nice place for discussions related to web designing and coding. We help our members to code their own website templates with HTML and CSS. We give them advice on various issues.

To know more about WebArtz Forum, visit the About Us page.

At the moment, you are viewing the forum as a guest. As a guest you can't make post and participate in discussions. You need to register and become a member of the forum. Click the register link below and become a part of this forum.

Thank You

You are not connected. Please login or register

View previous topic View next topic Go down  Message [Page 1 of 1]

1 Javascript - LogIn form on Thu May 24, 2012 3:28 am


Mr. WebArtz
Mr. WebArtz
Hello members of WebArtz forum, I am Mr.Joker and today I will show you how to make a simple login page. I must tell you that you should not use javascript for LogIn EVER, EVER, EVER, EVER AND NEVER. This is only like valiadation form not login because everyone can see from source code the username and password you enter. For Loging in we use PHP. Ok here is code:

<title>Javascript - Forms</title>
<script type="text/javascript">
function test() {
var userName = document.Form1.Element1.value;
var password = document.Form1.Element2.value;
if ((userName=="WebArtz") && (password=="I love it")) {
} else {
<form name="Form1">
<span>Enter Username</span>
<input type="text" name="Element1"/>
<span>Enter password:</span>
<input type="text" name="Element2"/>
<input type="button" value="Click me" onClick="test()"/>

This is really simple. You allready know how forms and elements function with javascript, and you also know advanced else if statement. We have Username and Password field. Now, when someone want to login we need to make a function that happen. So, we create two variables to take values from fields as I explained in last tutorial, and now we make a statement. With first condition I say if userName is equal to "WebArtz" and password is equal to "I love it" then javascript will redirect me to WebArtz. Thats why I used:
Also there is else which mean if its not as first statement then redirect to something else and I used Google.

All questions you can ask in this thread. Wink

View previous topic View next topic Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum