Forum Moderators: open

Message Too Old, No Replies

Channeling submit action starting with [enter] without submiting

This form's info are sent through other frame.

         

phoenix_fly

3:41 pm on Jun 6, 2005 (gmt 0)

10+ Year Member



Hello my esteemed friends,

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

RonPK

6:11 pm on Jun 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hard to tell without knowing more about your function. I'd try this first;

onSubmit="GoLogin(); return false;"

phoenix_fly

9:18 pm on Jun 6, 2005 (gmt 0)

10+ Year Member



Here´s my function:

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.

RonPK

10:08 pm on Jun 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well then, try this:

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()">

phoenix_fly

12:50 am on Jun 7, 2005 (gmt 0)

10+ Year Member



Hey Ron,

It works just perfect now!

In fact the ¦¦ instead of && was unintensional. Your modification is more than right.

It seems all the problem was the onClick in that type=button, wich didn´t have the "return false" you suggested before.

Thanks a lot, pal!

phoenix_fly