HighDots Forums  

submitting a page

alt.html alt.html


Discuss submitting a page in the alt.html forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
sheldonlg
 
Posts: n/a

Default submitting a page - 05-20-2008 , 07:15 PM






I have the following:

<input type="image" src="images/submit.jpg" width="70" height="30"
border="0" onclick="validateRegister()" />

It is inside a form where:

<form action="register_submit.php" name="register" id="register"
method="post">

At the end of validateRegister() I have:

if (msg.length > 0) {
alert(msg);
} else {
document.register.submit();
}

after having built the msg based upon any errors. (It starts with
var msg = ''

What I am happening is that it alerts the message of all the errors
because msg.length > 0, but then it submits the page!!! Even if I
comment out the document.register.submit(), it still submits it.

How can it submit the page if not a single call is made to post and
there is not button for submit?

Reply With Quote
  #2  
Old   
BootNic
 
Posts: n/a

Default Re: submitting a page - 05-20-2008 , 07:35 PM






sheldonlg <sheldonlg> wrote in
news:ypmdnfVjedBd9K7VnZ2dnUVZ_gednZ2d (AT) giganews (DOT) com:

Quote:
I have the following:

input type="image" src="images/submit.jpg" width="70" height="30"
border="0" onclick="validateRegister()" /
Remove the onclick on the image submit.

Quote:
It is inside a form where:

form action="register_submit.php" name="register" id="register"
method="post"
Add onsubmit="return validateRegister();" to the form.

Quote:
At the end of validateRegister() I have:

if (msg.length > 0) {
alert(msg);
add return false;

Quote:
} else {
document.register.submit();
replace document.register.submit();
with return true;

Quote:
}

after having built the msg based upon any errors. (It starts with
var msg = ''

What I am happening is that it alerts the message of all the errors
because msg.length > 0, but then it submits the page!!! Even if I
comment out the document.register.submit(), it still submits it.
Input type="image" is your submit button.

Quote:
How can it submit the page if not a single call is made to post and
there is not button for submit?
Your submit button is the input image.

Javascript validation is only a courtesy to the user, do validate on the
server.

--
BootNic Tuesday May 20, 2008 8:35 PM
Don't worry about people stealing an idea. If it's original, you
will have to ram it down their throats.
*Howard Aiken*


Reply With Quote
  #3  
Old   
sheldonlg
 
Posts: n/a

Default Re: submitting a page - 05-20-2008 , 08:26 PM



BootNic wrote:
Quote:
sheldonlg <sheldonlg> wrote in
news:ypmdnfVjedBd9K7VnZ2dnUVZ_gednZ2d (AT) giganews (DOT) com:

I have the following:

input type="image" src="images/submit.jpg" width="70" height="30"
border="0" onclick="validateRegister()" /

Remove the onclick on the image submit.

It is inside a form where:

form action="register_submit.php" name="register" id="register"
method="post"

Add onsubmit="return validateRegister();" to the form.

At the end of validateRegister() I have:

if (msg.length > 0) {
alert(msg);

add return false;

} else {
document.register.submit();

replace document.register.submit();
with return true;

}

after having built the msg based upon any errors. (It starts with
var msg = ''

What I am happening is that it alerts the message of all the errors
because msg.length > 0, but then it submits the page!!! Even if I
comment out the document.register.submit(), it still submits it.

Input type="image" is your submit button.
Thanks.

Quote:
How can it submit the page if not a single call is made to post and
there is not button for submit?

Your submit button is the input image.
Uh, no, not the way I had it coded. All it is is a button that invokes
a javascript. It knows nothing about submitting.

Quote:
Javascript validation is only a courtesy to the user, do validate on the
server.


Reply With Quote
  #4  
Old   
sheldonlg
 
Posts: n/a

Default Re: submitting a page - 05-20-2008 , 09:10 PM



BootNic wrote:
Quote:
sheldonlg <sheldonlg> wrote in
news:ypmdnfVjedBd9K7VnZ2dnUVZ_gednZ2d (AT) giganews (DOT) com:

I have the following:

input type="image" src="images/submit.jpg" width="70" height="30"
border="0" onclick="validateRegister()" /

Remove the onclick on the image submit.

It is inside a form where:

form action="register_submit.php" name="register" id="register"
method="post"

Add onsubmit="return validateRegister();" to the form.

At the end of validateRegister() I have:

if (msg.length > 0) {
alert(msg);

add return false;

} else {
document.register.submit();

replace document.register.submit();
with return true;
That worked. Thanks.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.