I'm having a problem with onSubmit. I'm building a little mobile website using jQTouch and. I want to call a function with onSubmit, if the user hits Enter, but that does not work. I really don't know what's the problem, because the function works perfectly, when it's called by onclick.
So here's the HTML:
<form action="" method="get" name="form1" onSubmit="calculateValue1();return false">
<ul>
<li>
Input 1 <input id="input1" name="input1" type="number"/>
</li>
<li>
Input 2 <input id="input2" name="input2" type="number"/>
</li>
</ul>
</form>
<a onclick="calculateValue1()">Calculate</a>
And here's the javascript for the function calculateValue1():
function calculateValue1() {
M = window.form1.input1.value;
n = window.form1.input2.value;
if (window.form1.input1.value=="") {
alert("Value missing");
}
}
When clicking on the link with onclick, the function works. When the focus is in input field 1 and I hit enter, nothing happens.
What could be the problem with this? I don't get an error message when hitting enter, I really don't know what's the problem with onSubmit.