我写了一个多文件上传的东西!需要判断file 是否有值 !如果没有值刚页面不能提交!
 <script type="text/javascript">
 function getValue()
 {
 var x=document.getElementById("docId").value;
 if(x=="")
 {
 alert("请选择文件");
 } }
 </script>
<form action="actions/modifyRecordAction!update?document.id=${document.id}" method="post" enctype="multipart/form-data" name="form1" onsubmit="return getValue()" >但在弹出alert()后页面还是会提交! 

解决方案 »

  1.   

    try
    getValue() ;return false;
      

  2.   

     function getValue()
     {
     var x=document.getElementById("docId").value;
     if(x=="")
    {
    alert("请选择文件");
    return false;
    }
    return true;
     }
      

  3.   

    <script type="text/javascript">
     function getValue()
     {
     var x=document.getElementById("docId").value;
     if(x=="")
    {
    alert("请选择文件");
    return false;
    }
    return true;
     }
     </script>
    加上红色的
      

  4.   

    <form action="actions/modifyRecordAction!update?document.id=${document.id}" method="post" enctype="multipart/form-data" name="form1" onsubmit="return getValue()" >还需要return 吗!