function validate(){ var flag=true; var fujianurl=document.getElementById("fujianshangchuanform:fieldsDataTable-402883aa2ba88bca012ba903775b0420:0:FJ_F_URL-402883aa2ba88bca012ba903775b0420").value; var biaoti=document.getElementById("fujianshangchuanform:fieldsDataTable-402883aa2ba88bca012ba903775b0420:0:FJ_NAME-402883aa2ba88bca012ba903775b0420").value; if(biaoti==""){ alert("附件名称不能为空,请重新添加"); return false; } if(biaoti.trim()==""){ alert("附件名称不能全为空格,请重新添加"); return false; } if(fujianurl==""){ alert("请选择上传的文件,请重新添加"); return false; } return flag; }
***************************************************************************************************************************************************************
<cf:dialog header="附件上传:" widgetVar="fujianshangchuandialog" modal="true" width="700" height="450" showEffect="drop" hideEffect="drop"> <h:form id="fujianshangchuanform" enctype="multipart/form-data" οnsubmit="return validate(this);"> <h:inputHidden value="#{ziliaoguanlimokuai_tblfujian_detailBean.title}" /> <t:fieldset legend="附件详细页面" styleClass="blue_b"> <h:panelGrid width="100%" border="0" cellspacing="0" cellpadding="0"> <rich:dataTable id="fieldsDataTable-402883aa2ba88bca012ba903775b0420" var="dataTb" columnClasses="richtable_col_right,richtable_col_left" width="100%" cellpadding="0" cellspacing="0" border="0" value=""> <rich:columnGroup style="width:100%"> <rich:column styleClass="query_col_label" style="text-align:right"> <h:outputText value="附件名称:" /> </rich:column> <rich:column styleClass="query_col_value"> <h:inputHidden id="FJ_NAME-402883aa2ba88bca012ba903775b0423232" value="#{ziliaoguanlimokuai_tblfujian_detailBean.dtoInfo.fjFUrl}"> </h:inputHidden> <h:inputText id="FJ_NAME-402883aa2ba88bca012ba903775b0420" size="20" value="#{ziliaoguanlimokuai_tblfujian_detailBean.dtoInfo.fjName}"> <f:validateLength maximum="400" /> </h:inputText> <rich:message styleClass="font_red" for="FJ_NAME-402883aa2ba88bca012ba903775b0420" /> </rich:column> <rich:column styleClass="query_col_label" style="text-align:right"> <h:outputText value="附件:" /> </rich:column> <rich:column styleClass="query_col_value"> <t:inputFileUpload id="FJ_F_URL-402883aa2ba88bca012ba903775b0420" value="#{ziliaoguanlimokuai_tblfujian_detailBean.file_fj_f_url}" styleClass="button-02" /> <rich:spacer width="10px" /> <h:commandLink id="FJ_F_URL-D55ABE208B2F400FA60356658555CF82" value="#{ziliaoguanlimokuai_tblfujian_detailBean.file_fj_f_url_name}" actionListener="#{ziliaoguanlimokuai_tblfujian_detailBean.downloadAction}" immediate="true"> <f:param name="url" value="#{ziliaoguanlimokuai_tblfujian_detailBean.dtoInfo.fjFUrl}" /> </h:commandLink> </rich:column> <rich:column breakBefore="true" styleClass="query_col_label" style="text-align:right"> <h:outputText value="附件备注:" /> </rich:column> <rich:column colspan="3" styleClass="query_col_value"> <h:inputTextarea id="FJ_BZ-402883aa2ba88bca012ba903775b0420" styleClass="textarea" cols="20" rows="5" value="#{ziliaoguanlimokuai_tblfujian_detailBean.dtoInfo.fjBz}"> <f:validateLength maximum="2000" /> </h:inputTextarea> <rich:message styleClass="font_red" for="FJ_BZ-402883aa2ba88bca012ba903775b0420" /> </rich:column> <h:inputHidden id="FJ_GLB_ID-402883aa2ba88bca012ba903775b0420" value="#{ziliaoguanlimokuai_tblfujian_detailBean.dtoInfo.fjGlbId}" /> </rich:columnGroup> </rich:dataTable> <rich:dataTable id="buttonDataTable402883aa2ba88bca012ba903775b0420" var="dataTb" columnClasses="query_col_bottom" width="100%" cellpadding="0" cellspacing="0" border="0" value=""> <rich:columnGroup style="width:100%"> <rich:column id="addButton402883aa2ba88bca012ba903775b0420" style="width:100%;text-align:right"> <h:panelGroup> <h:commandButton value="我要上传" action="#{ziliaoguanlimokuai_tblfujian_detailBean.uploadFileAction}" styleClass="button-02" /> <a4j:commandButton value="取消" styleClass="button-02" οnclick="fujianshangchuandialog.hide();return;" />//不进行表单校验 </h:panelGroup> </rich:column> </rich:columnGroup> </rich:dataTable> </h:panelGrid> </t:fieldset>
</h:form> </cf:dialog>