Click to See Complete Forum and Search --> : submit a form


uncoke
06-26-2007, 03:52 AM
Hello

I have a form with:
- not submit button but with an image instead of it with an <a href= "javascript:validateform()">
- no action
- an OnSubmit=validateform()

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

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

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

samanyolu
06-26-2007, 04:34 AM
document.getElementsByTagName('registration')[0]

uncoke
06-26-2007, 05:13 AM
ops, sorry, it was. Just a re-typing error.

I've also tryed
window.onload=function() {
document.getElementsByTagName('registration')[0].onsubmit=alert("ok");}

But is don't works...

The form is like this

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

I have tryed also

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


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

samanyolu
06-26-2007, 04:46 PM
my.js

window.onload=function() {
document.getElementsByTagName('form')[0].onsubmit= function() { alert("ok"); };
}



<html>
<head>
<script type="text/javascript" src="my.js"></script>
</head>
<body>
<form method="POST" name="registration" id="registration" action="a.php">

<input type="submit" value="submit me">

</form>

\\.\
06-27-2007, 05:19 AM
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?