function check(a){
  if(form1.xm.value=="")
   {
      for(i=1;i<=2;i++)
    {
     document.getElementById("xm"+i).style.display="none";
 document.getElementById("xm"+a).style.display="block";
 }
  
}
}
<form action=""  method="post" name="form1" onclick="return check(2)">
<input type="text" name="xm"  ><span class="STYLE3"  id="xm1">*</span><span class="STYLE3" style="display:none" id="xm2">请填写姓名</span>
<input type="submit" value="提交" style="width:60px; height:30px">&nbsp;&nbsp;&nbsp;<input type="reset" value="重写" style="width:60px; height:30px">
</form>
点击提交没有任何反应,这里是不是JS代码写错了,请高手给我看一下请教一下谢谢