PDA

View Full Version : help!!



reigalz
11-21-2002, 05:14 AM
hi, i'm doing a login page for administrators. When the admin have entered the user name, password and have chosen the organisation which they are in, they would click the Log-In button to continue. Is there any way that when the admin have entered all the details and he/she just have to press Enter on the keyboard to continue instead of clicking the Log-In button?
thanks!

here's my code, it's a jsp file:

<html>

<head>
<title>Administrator Login</title>

<script language="javascript">

function checking(name, password) {

if(name.length==0) {

window.alert("Please enter user name!");

document.login.user_name.focus();

} else if(password.length==0) {

window.alert("Please enter password!");

document.login.user_pass.focus();

} else {

login.submit();

}

}

</script>

</head>

<body onLoad="document.login.user_name.focus()">

<center>
<h1><font color="blue">Administrator Login</font></h1>
</center><hr><br>

<br><br>

<form name="login" action="admin_check.jsp" method="post">

<table align="center">

<tr>
<td><b>User name :</b></td>
<td><input type="text" name="user_name" size="15"></td>
<tr>

<tr>
<td><b>Password :</b></td>
<td><input type="password" name="user_pass" size="15"></td>
</tr>

<tr>

<td><b>Organisation :</b></td>

<td>
<select name="org_options">
<option>Cathay</option>
<option>Eng_Wah</option>
<option>Golden_Village</option>
<option>Shaw_Brothers</option>
</select>
</td>

<td align="right"><input type="button" value="Log-in" onClick="checking(document.login.user_name.value, document.login.user_pass.value)"></td>

</tr>

</table>

</form>

<br>

<center>Note: User ID and password is <b>NOT</b> case-sensitive.</center>

</body>

</html>

firepages
11-21-2002, 10:03 AM
changing this

input type="button"

to

input type="submit"

may do the trick

Roelf
11-25-2002, 11:02 AM
afaik, the onclick event should be changed into an onsubmit event, if the user hits enter, there wont be an onclick event anymore