Instead of using a submit button on my form I am using an image with an onclick function. My field validation function will therefore not execute when that image/button is clicked. The form was created with GoLive, and the functions associated with the image/button are necessary, so I don’t know that I can change that. So, I tried using onunload, which execute the validation function OK, but of course, if there are any errors, the next page is displayed regardless.
Does anyone have any suggestions how to get around this?
Maybe it is just a syntax issue that someone else might notice?
Here is some of the code in question:
<script type="text/javascript">
function validate_fields() {
for (x=0; x<document.pagethree.elements.length; x++) {
if (document.pagethree.elements[x].value == "") {
alert("Required fields are blank!.")
break; }
}
return false;
}
</SCRIPT>
<form onsubmit="validate_fields()">
<a title="Click to advance to next page" onclick="CSAction(new Array(/*CMP*/'62802300'));return CSClickReturn();" href="#" csclick="62802300"><img src="images/button_right_arrow.gif" alt="Click to advance to next page" name="mySubmit" height="50" width="50" border="0"></a>
When I do it like this, I get an error when I change the above to <input type="image"> that says mySubmit is null or not an object….
<input type="image" src="images/button_right_arrow.gif" title="Click to advance to next page" onclick="CSAction(new Array(/*CMP*/'62802300'));return CSClickReturn();" href="#" csclick="62802300" alt="Click to advance to next page" name="mySubmit" height="50" width="50" border="0"></div>
You can see the two examples at:
http://www.tdavisconsulting.com/kenerly/page03c.html
http://www.tdavisconsulting.com/kenerly/page03d.html
Thanks,
-tdavis