qq_23848895 2017-06-15 06:44 采纳率: 0%
浏览 997

关于html表单提交问题

我有如下两个表单
图片说明
但是我第二表单填写完好后,还是会提示,有某某地方输入为空。
代码如下:

function btnAction() { document.getElementById('file').click(); } function checkLogin(){ var name=window.document.getElementById("name").value; var intro=window.document.getElementById("introduction").value; var percent=window.document.getElementById("percentOfGreat").value; var months=window.document.getElementById("monthOfsales").value; var aver=window.document.getElementById("averagePrice").value; var img=window.document.getElementById("file").value; window.alert(img); if (name ==""||intro==""||percent==""||months==""||aver=="") // 或者是!nameValue { window.alert("有输入为空!请检查重新输入"); return false; } if(img==""){ window.alert("未上传图片或者二维码,请检查"); return false; } return true; }
    <div class="content-wrap">
        <section id="section-circlefill-1">
            <span>表单1</span>

            <form action="test2.php?id=1" method="post" enctype="multipart/form-data" onsubmit="return checkLogin();">
                                <input type="text" id="name" name="name" placeholder="名称"/>
                                <input type="text" id="introduction" name="introduction" placeholder="简介"/>
                                <input type="text" id="percentOfGreat" name="percentOfGreat" placeholder="好评率"/>
                                <input type="text" id="monthOfsales" name="monthOfsales" placeholder="月销售量"/>
                                <input type="text" id="averagePrice" name="averagePrice" placeholder="平均商品价格"/>
                                <input type="file" name="file" id="file" style="visibility: hidden; " />
                                <button type="button" id="myBtn" class="save" onclick="btnAction()"  >上传微信二维码</button>
                                <button type="submit" class="submit" name="submit">上传</button>
                            </form>
            </section>

        <section id="section-circlefill-2">
            <span>表单2</span>
            <form action="test2.php?id=2" method="post" enctype="multipart/form-data" onsubmit="return checkLogin();">
                                <input type="text" id="name2" name="name" placeholder="推荐微商名称"/>
                                <input type="text" id="introduction2" name="introduction" placeholder="简介"/>
                                <input type="text" id="percentOfGreat2" name="percentOfGreat" placeholder="好评率"/>
                                <input type="text" id="monthOfsales2" name="monthOfsales" placeholder="月销售量"/>
                                <input type="text" id="averagePrice2" name="averagePrice" placeholder="平均商品价格"/>
                                <input type="file" name="file2" id="file2" style="visibility: hidden; " />
                                <button type="button" id="myBtn" class="save" onclick="btnAction()"  >上传微信二维码</button>
                                <button type="submit" class="submit" name="submit">上传</button>
                            </form>

        </section>
  • 写回答

5条回答 默认 最新

  • qq_23848895 2017-06-15 06:51
    关注
    function btnAction() { document.getElementById('file').click(); } function checkLogin(){ var name=window.document.getElementById("name").value; var intro=window.document.getElementById("introduction").value; var percent=window.document.getElementById("percentOfGreat").value; var months=window.document.getElementById("monthOfsales").value; var aver=window.document.getElementById("averagePrice").value; var img=window.document.getElementById("file").value; window.alert(img); if (name ==""||intro==""||percent==""||months==""||aver=="") // 或者是!nameValue { window.alert("有输入为空!请检查重新输入"); return false; } if(img==""){ window.alert("未上传图片或者二维码,请检查"); return false; } return true; }
    评论

报告相同问题?

悬赏问题

  • ¥15 Matlab问题解答有两个问题
  • ¥50 Oracle Kubernetes服务器集群主节点无法访问,工作节点可以访问
  • ¥15 LCD12864中文显示
  • ¥15 在使用CH341SER.EXE时不小心把所有驱动文件删除了怎么解决
  • ¥15 gsoap生成onvif框架
  • ¥15 有关sql server business intellige安装,包括SSDT、SSMS。
  • ¥15 stm32的can接口不能收发数据
  • ¥15 目标检测算法移植到arm开发板
  • ¥15 利用JD51设计温度报警系统
  • ¥15 快手联盟怎么快速的跑出建立模型