• 用JS怎么判断上传文件控件是否未选择文件


    页面代码:

        <form name="form1" action="uploadPosdetailFile.html" method="post" ENCTYPE="multipart/form-data">
        <div class="form" >
                <p>
                    <span class="req"><input id="startDateTxt"  name="startDateTxt" class="field size4" title="Enter the date" /></span>
                    <label>Start Date: <span>(Date format:MM/dd/yyyy,eg:01/01/2014)</span></label>
                </p>
                
                <p>
                    <span class="req"><input id="endDateTxt"  name="endDateTxt" class="field size4" title="Enter the date" /></span>
                    <label>End Date: <span>(Date format:MM/dd/yyyy,eg:12/25/2014)</span></label>
                </p>
                
                <p>
                    <span class="req"><input type="file"  name="uploadFileCtrl" class="field size4" title="Choose the file" /></span>
                    <label>Upload file: <span>(click browse to choose)</span></label>
                </p>
        </div>
        
        <div class="buttons">
            <input id="queryBtn" type="button" class="button" value="Submit" />
        </div>
        
        </form>

    验证代码:

        $("#queryBtn").click(
            function(){
                ......
                
                var s=document.form1.uploadFileCtrl.value; 
                if(s==""){
                    alert("Please choose a posdetail file.");
                    document.form1.uploadFileCtrl.focus();
                    return;
                }
                
                showLoadingWnd('Uploading,please wait...');
                document.form1.submit();
            }
        );

    上面粗体部分是核心代码。

    没有什么,留些印记而已。

  • 相关阅读:
    单实例GI数据库彻底清除
    crsctl & srvctl
    Err "CLSU-00104: additional error information: need ha priv"
    Err "Kernel panic
    安装JRE
    华为-RH5885 V3 远程KVM
    Swagger与OAuth 手动搭建WebApi 操作笔记
    xib自定义View
    iOS回收键盘
    iOS设置用户头像(从相册,图库或者拍照获取)
  • 原文地址:https://www.cnblogs.com/heyang78/p/4125940.html
Copyright © 2020-2023  润新知