/    Sign up×
Community /Pin to ProfileBookmark

submit a form

Hello

I have a form with:

[QUOTE]

– not submit button but with an image instead of it with an <a href= “javascript:validateform()”>
– no action
– an OnSubmit=validateform()

[/QUOTE]

This is working but if I press Enter key this made a relod of page and jump the validating…

Maybe I must use a window.onLoad just like this

[QUOTE]

window.onload=function() {
document.getElementsByTagName(‘registration’)0].onsubmit=validateForm;
}

[/QUOTE]

But it is not working… maybe i have to put the form action or maybe i have to check the Dreamwevaer code (in the page there is some code by dreamweaver to insert into the DB after submit…)

I’ll check it later, if you have some suggestions I’ll apreciate it.

thanks

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@samanyoluJun 26.2007 — document.getElementsByTagName('registration')[color=red][[/color]0]
Copy linkTweet thisAlerts:
@uncokeauthorJun 26.2007 — ops, sorry, it was. Just a re-typing error.

I've also tryed

window.onload=function() {

document.getElementsByTagName('registration')[0].onsubmit=alert("ok");}[/QUOTE]


But is don't works...

The form is like this

<form action="<?php echo $editFormAction; ?>" method="POST" name="registration" id="registration" >...</form>[/QUOTE]

I have tryed also

<form method="POST" name="registration" id="registration" >...</form>[/QUOTE]


Hmm... but is my window.onload function right ?

Where i have to put that functions ? I have an external file.js... loaded from the <head> of the html file. Is it right ?

Thanks for your help
Copy linkTweet thisAlerts:
@samanyoluJun 26.2007 — my.js
<br/>
window.onload=function() {
document.getElementsByTagName('[color=red]form[/color]')[0].onsubmit= function() { alert("ok"); };
}


<br/>
&lt;html&gt;
[color=red]&lt;head&gt;[/color]
&lt;script type="text/javascript" src="my.js"&gt;&lt;/script&gt;
[color=red]&lt;/head&gt;[/color]
&lt;body&gt;
&lt;form method="POST" name="registration" id="registration" action="a.php"&gt;

&lt;input type="submit" value="submit me"&gt;

&lt;/form&gt;
Copy linkTweet thisAlerts:
@rootJun 27.2007 — You are trying to add a onsubmit event to a form that has no submit button, so how are you..

Client-side: How are you submitting the form without the submit button?

server-sided: How can you tell its a form without testing to see if the Submit button is present?
×

Success!

Help @uncoke spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...