JSF Photo Upload を jQuery validate で検証しようとしていますが、うまくいきません。形 :
<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ライブラリもインポートしました...