This is a snippet of the code. I want to validate when they click on the image and submit ONLY if there are no errors. The problem that I ma having is that as soon as i clik ok on the alert button it is submitting.
If i change the last image to be a type Button, then it works like a charm.
<form name="SubmitCanvasOrder" action="ValidateOrder.jsp"
method="post" onsubmit="check('SubmitCan
vasOrder',
'image');">
Shipping Name:
<input name="name" id="name" size="30" maxlength="50" type="text" />
<br />
Address - Line 1
<input name="address1" id="address1" size="30" maxlength="50" type="text" />
<br />
Address - Line 2
<input name="address2" id="address2" size="30" maxlength="50" type="text" />
<br />
City:
<input name="city" id="city" size="30" maxlength="50" type="text" />
<br />
State:
<input name="state" id="state" size="7" maxlength="50" type="text" />
<br />
Zip Code
<input name="zip" id="zip" size="9" maxlength="50" type="text" /><br />
<input name="image" type="image" onclick="check('SubmitCanv
asOrder', 'image');" />
</form>
function checkThisForm(formname, submitbutton, errors) {
if (errors == '')
{
eval(formname+'.'+submitbu
tton+'.dis
abled=true
');
eval('document.'+formname+
'.submit()
');
}
else
{
alert(errors);
}
}
function check(formname, submitbutton) {
var errors = '';
errors += checkText(formname, 'name', 'Name');
errors += checkText(formname, 'address1', 'Address');
errors += checkText(formname, 'city', 'City');
errors += checkText(formname, 'state', 'State');
errors += checkText(formname, 'zip', 'Zip');
checkThisForm(formname, submitbutton, errors);
}
Start Free Trial