Beginner question: form submit

S

soup_or_power

My form looks as follows. Why isn't the function Validate called when
the function test is called? Thanks for your help!!

function Validate()
{
alert("in validate");
}

function test()
{
//do something
document.forms[0].submit;
}
<FORM method="POST" onsubmit="return Validate()">
....
<input type=text value="xyz" onclick="test()">
</FORM>
 
L

LV_Indy

Because you aren't calling submit as a function:

document.forms[0].submit();

You are basically asking if submit exists, which is does. But you are
doing nothing with it, so nothing's happening.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top