I am using multipart to upload a file; I want to prevent the form from being submitted if the file has not been selected.
How can I achieve this ? This is my code:
<form id="uploadFile" name="uploadFileForm" action="<s:url value="/admin/saveExcelDatarestore" />" method="post" enctype="multipart/form-data"><span>
<input type="hidden" name="s360securetoken" value="<s:property value="#session.s360securetoken"/>"/>
<s:hidden name="user.userId"></s:hidden>
<s:hidden name="user.emailId"></s:hidden>
<div><label>DownLoad Sample :</label><input type="button" class="submit" value="XLS" onclick="dnldSampleData('XLS');"></span></div>
<div><label>Upload File :</label> <input type="file" name="upload" value="" id="uploadFile_upload"></span>
<span><select id="selectedTimeZone" name="timeZone" style="width:100%;white-space: nowrap; overflow: hidden;" class="chosen-select1">
<jsp:include page="../../../../timezone.jsp"/>
</select></span><div>
<input type="submit" value="upload" class="submit" onclick="upload_file();"></form>
Here if I do not select file it's also redirecting tme to saveExecelDatarstore
, but I want that if there is no file selected then it shoud not show any message, and return back