这种情况下该如何验证?
<logic:notEmpty name="adminInfoForm" property="notVerifiedProductionList"> <logic:iterate id="production" name="adminInfoForm" property="notVerifiedProductionList" indexId="index"> <bean:write name="production" property="title"/> <bean:write name="production" property="authors"/> <bean:write name="production" property="time" format="yyyy-MM-dd"/> <bean:write name="production" property="place"/> <html:form action="/adminInfo" method="post" enctype="multipart/form-data" onsubmit="javascript:return check();"> <html:hidden property="method" value="uploadFile"/> <input type="hidden" name="productionId" value="<bean:write name='production' property='id'/>"/> 上传文件:<html:file property="myFile"></html:file> <input type="submit" value="上传"/> </html:form> </logic:iterate></logic:notEmpty>
function check(){ var len = document.all.myFile.value.length; var str = document.all.myFile.value; var xx = str.substr(str.lastIndexOf("."),len); if(xx == ".pdf"){ return true; } else{ alert("必须上传PDF格式文件"); return false ; }}