Forum Moderators: open
I´m using the button type=button, and a onCLick event handler on it, wich deals perfectly with the javascript routine "GoLogin" that sends the info through the other frame I have.
But the thing is that when the user hits \[enter\], nothing happens, as I´ve put a "return false" on the onSubmit handler of the form, to avoid that info being submitted through that frame, you know?
I´ve tried to put the GoLogin in the onSubmit, but it then doesn´t keep the main frame from wrongly refreshing. And if I put "return GoLogin" on it, and put "return false" inside GoLogin function, then it doesn´t make anything at all, not even triggering the other frame.
Here´s the form:
<form name=formlogin onSubmit="return GoLogin">
<input type=text name=username>
<input type=password name=password>
<inút type=button value="Login" onClick="GoLogin();">
Maybe if I put the "return false" at the end of the GoLogin function? As the last line?
I wait for your help then,
phoenix_fly
function GoLogin () {
var username = document.formlogin_menu.username.value;
var pw = document.formlogin_menu.pw.value;
if ( username!= "" ¦¦ pw!= "" ) {
parent.frames[0].location='$dominio_ssl/cgi-bin/login.cgi?username=' + username + '&pw=' + pw;
}
}
I´ve tried what you said too, but then nothing happens when I press the [enter] key, after typing the last letter of the password.
function GoLogin () {
var username = document.formlogin_menu.username.value;
var pw = document.formlogin_menu.pw.value;
if ( username!= "" && pw!= "" ) {
parent.frames[0].location='$dominio_ssl/cgi-bin/login.cgi?username=' + username + '&pw=' + pw;
} else {
alert("Please enter a username and a password.");
}
return false;
} Note that I replaced the OR (¦¦) by AND (&&) ; that way you're more sure that the user entered both username and password.
Also, there's no need for the onclick-handler on the button: it works as a submit button, so adding the onsubmit handler to the form should be enough.
<form onsubmit="return GoLogin()">