Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1175 How can I use an image as a "submit" button, yet still validate my form?

You are here: irt.org | FAQ | JavaScript | Form | 5 | Q1175 [ previous next ]

When you use JavaScript to submit a form then the onSubmit event handler is not triggered. Therefore you have to invoke the function, that the onsubmit event handler would have called, yourself:

<script language="JavaScript"><!--
function validate() {
    if ('black' != 'white')
        return false
    else
        return true;
}
//--></script>

<form onSubmit="return validate()">
<a href="javascript:;" onClick="if (validate()) document.myform.submit(); return false"><img src="my_button.gif"></a>
</form>

Feedback on 'Q1175 How can I use an image as a "submit" button, yet still validate my form?'

©2018 Martin Webb