Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

two onclick functions?

Status
Not open for further replies.

boyfromoz

Technical User
Feb 1, 2001
469
AU
I have a form that I need to validate and submit. No problem if the form button is a normal slab button, but I am using the form button fever extension which allows forms to be submitted by a rollover.

problem is, if I use onclick for my form validation, I can't use it to then submit the form?

Any suggestions for a work around?

 
Hi nippi!

First.
English is not my native language so I'm not sure that I understand you right. What is slab button and fever extension?

You may have as many functions as many you need just separate them by ;
like this:
<.... onClick=&quot;ValidateForm(); SubmitForm()&quot;>


Second.
If you need to validate and then submit the form the best solutiond is to return value of ValidateForm() function (true if everything's correct ans false otherway) to submit form. I usually do it like this:

<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;file.asp&quot; onSubmit=&quot;return CheckOnSubmit()&quot;>
<input ...>
<input ...>
<input type=&quot;submit&quot;>
</form>

...and somewhere above JS function:

function CheckOnSubmit()
{
var e=&quot;&quot;,df=document.form1;
if (df.Name.value == &quot;&quot;) e+=&quot; Name is required &quot;;
if (e)
{
alert(e);
return false; //if form NOT OK
}
else { return true; } //if form OK
}

Is it what you need or am I wrong?

Good Luck!
 
You have very good English,its my lack of description that is the problem. I'll have another go.

<input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Submit&quot;>

The code above generats what I clal a &quot;slab&quot; button. A grey ugly thing.
To submit my forms, I have been trying to use a behaviour, which can be &quot;added on&quot; to dreamweaver. this behaviour isnerts a bit of javascript code that is supposed to allow me to use any object to submit a form.

Checkitout at
Its called form button fever.

Effectively it works as a javscript function that submits my form when I click on my image, but if I use this behaviour&quot;onclick&quot; I can't also use onclick for a form validation.

See my problem now?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top