如何使用jQuery验证JSF Photo Upload

时间:2012-12-09 06:50:19

标签: jquery jsf tomahawk

我正在尝试通过jQuery验证来验证JSF Photo Upload,但它不起作用。 形式:

<h:form id="uploadForm" name="uploadForm" enctype="multipart/form-data">
                <table>
                <tr>
                    <h:outputText for="file" value="Select Photo : " />
                    <t:inputFileUpload id="file1" name="file1" value="#{companyService.uploadedFile}" required="true" />
                    <h:message for="file" style="color: red;" />
                </tr>
                <tr>
                <td></td>
                <h:commandButton value="Upload" styleClass="add" action="#{companyService.uploadPhoto}" />
                    <h:message for="uploadForm" infoStyle="color: green;" errorStyle="color: red;" />
                </tr>
                </table>
 </h:form>

脚本:

<script type="text/javascript">
$(document).ready(function(){
    //$('textarea').elastic();
    $("#uploadForm").validate({
        rules: {
            file1: {
                required: true,
                accept: "jpg|gif|png|jpeg"
            }
        },
        messages: {
            file1: "jpg,gif,png,jpeg extensions are allowed"
        }
    });
})
</script>

我也导入了jQuery库......

0 个答案:

没有答案