hi everyone
well the problem is while using image instead of button or submit input types (for my own reasons)and trying to validate some fields deciding whether to submit the form or not. The image tag sends it anyway.
I call a function to validate my fields from the onclick field in my image input tag, but it submits the form even if I leave the body of the validate function empty! how can I stop it from submiting the form?
please help

.
.
<script language="javascript">
<!--
function validate(){
if(document.form1.username=="")
alert("empty field!");
else document.form1.submit();
}
-->
</script>
.
.
.
<form name="form1" method="post" action="/LearningJSTL-Project-context-root/Do.do;jsessionid=c6646544231ccb316b5ef1b74feba23ce d8cb5de2bbf" enctype="multipart/form-data">
<div align="center">
<input type="image" name="y" src="x" onclick="validate()"><br>
<input type="text" name="userName" value=""><br>