lifeseries Posted August 14, 2006 Share Posted August 14, 2006 hi, i have a login javascript coding which now is using mouse to hit the enter button to accept username and password, can you guy help me that after user type in password, he or she just need to hit the keyboard enter key instead of using mouse to click the enter button.Thank... Link to comment Share on other sites More sharing options...
skym Posted August 14, 2006 Share Posted August 14, 2006 If the button is submit type (type="submit") and the user did not focus outside the form fields, the Enter key should work. Link to comment Share on other sites More sharing options...
joecoolaug Posted August 15, 2006 Share Posted August 15, 2006 hi, i have a login javascript coding which now is using mouse to hit the enter button to accept username and password, can you guy help me that after user type in password, he or she just need to hit the keyboard enter key instead of using mouse to click the enter button.Thank...It would help if you could either give me the code or the URL Link to comment Share on other sites More sharing options...
lifeseries Posted August 15, 2006 Author Share Posted August 15, 2006 Here are the codes, hope you can help me..thankz....<html> <head> <title>goto</title> <script LANGUAGE="JavaScript">// ** Functions() (NON-EDITABLE)function LogIn(){loggedin=false;password = document.getElementById('pass').value;password = password.toLowerCase();username = document.getElementById('user').value;username = username.toLowerCase();// ** Login Names and P-words (EDITABLE)if (username=="aaa" && password=="bbb") { loggedin=true;window.location="goto.html";}// ** Alert for incorrect (EDITABLE BUT NOT RECOMENDED)if (username=="") alert("Please enter username."); elseif (password=="") alert("Please enter password."); elseif (loggedin==false) { alert("Login failed!\n\nPlease enter the correct username and password.");}}</SCRIPT> </head> <body onload="init();" ID="index" bgcolor="#eeeeee" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> <table width="800" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="white"> <tr> <td valign="top"> <table width="800" border="0" cellspacing="0" cellpadding="0" bgcolor="#eeeeee" height="8"> <tr> <td valign="top"></td> </tr> </table> <table width="800" border="0" cellspacing="0" cellpadding="0" align="center" height="126"> <tr height="126"> <td width="800" height="126" background="images/header.jpg"></td> </tr> </table> <table width="800" border="0" cellspacing="0" cellpadding="0" height="12"> <tr> <td> <div align="center"> </div> </td> </tr> </table> <table width="800" border="0" cellspacing="0" cellpadding="0" height="50"> <tr> <td> <div align="center"> <font size="5" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif"><b>WELCOME TO MAGNA DIGITAL ARCHIVING SERVICES</b></font></div> </td> </tr> </table> <table width="800" border="0" cellspacing="0" cellpadding="0" height="40"> <tr> <td></td> </tr> </table> <table width="800" border="0" cellspacing="0" cellpadding="0" height="146"> <tr> <td valign="top"> <table width="800" border="0" cellspacing="0" cellpadding="0" height="146"> <tr height="146"> <td width="242" height="146"></td> <td valign="top" width="316" height="146" background="images/greybox2.jpg"> <table width="316" border="0" cellspacing="0" cellpadding="0" height="146"> <tr height="30"> <td width="316" height="30"></td> </tr> <tr height="15"> <td width="316" height="15"></td> </tr> <tr height="30"> <td width="316" height="30"> <table width="316" border="0" cellspacing="0" cellpadding="0" height="30"> <tr height="30"> <td width="16" height="30"></td> <td width="61" height="30"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">username</font></td> <td width="140" height="30"><input type="text" id="user" name="user" size="21" maxlength="20" onfocus="if(this.value){ user.value = ''; }"></td> <td width="50" height="30"> <div align="center"> <img src="images/box.jpg" alt="" height="22" width="38" border="0"></div> </td> <td width="49" height="30"></td> </tr> </table> </td> </tr> <tr height="30"> <td width="316" height="30"> <table width="316" border="0" cellspacing="0" cellpadding="0" height="30"> <tr height="30"> <td width="16" height="30"></td> <td width="61" height="30"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">password</font></td> <td width="140" height="30"><input type="password" id="pass" name="pass" size="21" maxlength="20" onfocus="if(this.value){ pass.value = ''; }"></td> <td width="50" height="30"> <div align="right"> <input type="button" value="Go" onclick="LogIn();"></div> </td> <td width="49" height="30"></td> </tr> </table> </td> </tr> <tr height="41"> <td width="316" height="41"> </td> </tr> </table> </td> <td width="242" height="146"></td> </tr> </table> </td> </tr> </table> <table width="800" border="0" cellspacing="0" cellpadding="0" height="20"> <tr> <td> <div align="center"> </div> </td> </tr> </table> <table width="800" border="0" cellspacing="0" cellpadding="0" height="18"> <tr> <td> <div align="center"> <img src="images/line.jpg" alt="" height="1" width="433" border="0"></div> </td> </tr> </table> <table width="800" border="0" cellspacing="0" cellpadding="0" height="50"> <tr> <td> <div align="center"> <font size="4" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif"><b>BRINGING TOGETHER FILM AND DIGITAL TECHNOLOGY </b></font></div> </td> </tr> </table> <table width="800" border="0" cellspacing="0" cellpadding="0" height="80"> <tr height="80"> <td width="800" height="80"> <div align="center"> <img src="images/bottom.jpg" alt="" height="80" width="800" border="0"></div> </td> </tr> </table> <table width="800" border="0" cellspacing="0" cellpadding="0" height="13"> <tr> <td> <div align="center"> <img src="images/text.jpg" alt="" height="13" width="221" border="0"></div> </td> </tr> </table> </td> </tr> </table> </body></html> Link to comment Share on other sites More sharing options...
skym Posted August 15, 2006 Share Posted August 15, 2006 Here's a code that works: <html><head><title></title></head><script type="text/javascript"><!--function checkFields(obj) { if (obj.username.value == "") alert("Please type your username!"); else if (obj.password.value == "") alert("Please type your password!"); else obj.submit(); }//--></script><body><form name="login" action="goto.php" method="get" onsubmit="checkFields(this); return false;"><input name="username"><br><input name="password" type="password"><br><input name="submit" type="submit" value=" GO "></form></body></html> You should not use Javascript for login, anybody can see the username and password. Link to comment Share on other sites More sharing options...
lifeseries Posted August 15, 2006 Author Share Posted August 15, 2006 ya, i know, that why i'm gonna encrypt the code. can the code accept more than 1 username and password?is it a php script or javascript because i saw the goto.php action.if i stick with my coding, which part should i modify to make it accept the enter key from keyboard..thank... Link to comment Share on other sites More sharing options...
skym Posted August 15, 2006 Share Posted August 15, 2006 I have shown you the way I would do it, there would be a php file of course to process the form data, anyway you don't want to use it, so it doesn't matter.Replace your inputs with: <form name="login" action="" method="get" onsubmit="LogIn(); return false;"><input name="username" id="user"><br><input name="password" type="password" id="pass"><br><input name="submit" type="submit" value=" GO "></form> Should work the same as your code if I understood it correctly, but with the 'enter' working too. Link to comment Share on other sites More sharing options...
lifeseries Posted August 15, 2006 Author Share Posted August 15, 2006 my coding doesn't have a form in it, that mean i need to add a form, correct? Link to comment Share on other sites More sharing options...
skym Posted August 15, 2006 Share Posted August 15, 2006 correct Link to comment Share on other sites More sharing options...
joecoolaug Posted August 15, 2006 Share Posted August 15, 2006 Yep. All you have to do is add the form. I noticed that your login fields are separated by table columns. This might present a problem, but it might not. Link to comment Share on other sites More sharing options...
skym Posted August 15, 2006 Share Posted August 15, 2006 It's not a problem the code between the input fields. Just add the <form ...> before the first field, and </form> after the submit button.You might also want to put form{display:inline;} in the CSS to take out the line brake that the </form> generates. Link to comment Share on other sites More sharing options...
lifeseries Posted August 16, 2006 Author Share Posted August 16, 2006 Here is the code that i modified but seem like not working...Any idea?<html> <head> <meta http-equiv="content-type" content="text/html;charset=iso-8859-1"> <meta name="generator" content="Adobe GoLive"> <title>Untitled Page</title> </head> <script LANGUAGE="JavaScript">// ** Functions() (NON-EDITABLE)function LogIn(){loggedin=false;password = document.getElementById('pass').value;password = password.toLowerCase();username = document.getElementById('user').value;username = username.toLowerCase();// ** Login Names and P-words (EDITABLE)if (username=="c" && password=="cc") { loggedin=true;window.location="cc.html";}if (username=="a" && password=="aa") {loggedin=true;window.location="a.html";}if (username=="b" && password=="bb") { loggedin=true;window.location="bb.html";}// ** Alert for incorrect (EDITABLE BUT NOT RECOMENDED)if (username=="") alert("Please enter username."); elseif (password=="") alert("Please enter password."); elseif (loggedin==false) { alert("Login failed!\n\nPlease enter the correct username and password.");}}</SCRIPT> <body bgcolor="#ffffff"> <div align="center"> <table width="300" border="6" cellspacing="2" cellpadding="2" height="300"> <tr> <td> <div align="center"> <form id="login" action="" method="get" method="get" onsubmit="LogIn(); return false;"> <font size="-1" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif">username:</font><input type="text" name="textfieldName" size="24"><br> <font size="-1" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif">password:</font><input type="password" name="textfieldName" size="24"><br> <input type="button" name="submitbut" value="GO"> </form> </div> </td> </tr> </table> </div> <p></p> </body></html> Link to comment Share on other sites More sharing options...
Reg Edit Posted August 16, 2006 Share Posted August 16, 2006 Your answer is in the first reply to your original post!!! If the button is submit type (type="submit") and the user did not focus outside the form fields, the Enter key should work.The button input type has to be "submit"! Link to comment Share on other sites More sharing options...
lifeseries Posted August 17, 2006 Author Share Posted August 17, 2006 i had change the input type to submit, but when i enter the button, the username and password box will be clear instead of directing to other page...can you help me?tkz.... Link to comment Share on other sites More sharing options...
skym Posted August 17, 2006 Share Posted August 17, 2006 Also add id="user" to the username input and id="pass" to the password input. Link to comment Share on other sites More sharing options...
lifeseries Posted August 18, 2006 Author Share Posted August 18, 2006 its work..thank you so much...now i'm gonna encrypt it...so that other ppl won't see the password... Link to comment Share on other sites More sharing options...
nomore_sr Posted August 20, 2006 Share Posted August 20, 2006 its work..thank you so much...now i'm gonna encrypt it...so that other ppl won't see the password...Other ppl won't see the password if method="post" like this<form id="login" action="" method="post" onsubmit="LogIn(); return false;"> default method is post Link to comment Share on other sites More sharing options...
Reg Edit Posted August 21, 2006 Share Posted August 21, 2006 Other ppl won't see the password if method="post"Oh yes they will! The OP is talking about View Source, not the querystring. There is a desire to hard-code the pwd in the javascript (perhaps you missed that in the earlier posts?). It has been stated that this is a bad idea (I agree) but the OP wants to do it this way. Link to comment Share on other sites More sharing options...
ThePsion5 Posted August 21, 2006 Share Posted August 21, 2006 I'm very much tempted to agree. Even if you encrypt the password before placing it into the javascript file, they already have the encrypted version that they can just supply to your verification page! Also, since the user can disable javascript, using it as the sole method of logging in is a bad plan because when javascript is disabled one of two things will happen: either the user will not be able to log in no matter what, or the user will always be able to log in - probably the latter. Why not use server-side validation? Link to comment Share on other sites More sharing options...
lifeseries Posted September 7, 2006 Author Share Posted September 7, 2006 I also want to use PHP or ASP, but i don't know this kind of programming and somemore i'm using mac... Link to comment Share on other sites More sharing options...
scott100 Posted September 7, 2006 Share Posted September 7, 2006 I also want to use PHP or ASP, but i don't know this kind of programmingNot yet you don't, go here to learn them http://www.w3schools.com/ and somemore i'm using mac...so? it doesn't matter that your using a mac. ASP/PHP are run at the server so client machine is irrelevant, as long as you have a browser your jammin' Link to comment Share on other sites More sharing options...
businessman332211@hotmail.com Posted September 7, 2006 Share Posted September 7, 2006 pretty much, if you use javascript to password protect pages, a homeless person, who never had education could use your own passwords against you. You can encrypt them all you want, it's not going to change you have a security risk, I can even show you how easy it is, give me hte url, of the javascript password protected page, do whatever you want to with it, then send me the url, I can show you how dangerous it is to use javascript for (sensitive) password protected pages. Link to comment Share on other sites More sharing options...
lifeseries Posted September 8, 2006 Author Share Posted September 8, 2006 But my server is MAC also, can?....by the way, what are the difference between ASP and PHP if i want to learn... Link to comment Share on other sites More sharing options...
Chocolate570 Posted September 8, 2006 Share Posted September 8, 2006 They're just different. It's like saying what's the difference between javascript and vbscript. ASP is by microsoft and is much less common on servers, while php is open-source developed and is common. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now