• jquery表格提交验证


    在表格中的验证

    1.body中的内容

    <form action="http://www.qq.com" id="form1"><table width="200" border="1" cellspacing="0" cellpadding="0">
    <tr>
    <td><input id="a"/></td>
    <td><input id="b" /></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td colspan="2">&nbsp;</td>
    </tr>
    </table>
    <button type="submit">sssssssssssss</button>
    </form>

    2.jquery中的验证

    (1)在head中加入jquery文件<script src="../Js/jquery-1.7.1.min.js"></script>

    (2)在写入script语句

    <script>
    $(function(){
    //提交表单时触发的事件
    $("#form1").submit(function(){
    if($("#a").val()=="")
    {//验证表单是否为空
    alert("请填写A表单")//提示语
    $("#a").focus();//让光标放在id=a的表格,方便在多个id中快速查找
    return false;//停止运行
    }
    if($("#b").val()=="")
    {
    alert("请填写B表单");
    $("#b").focus();
    return false;
    }

    return true;
    })

    })

    </script>

  • 相关阅读:
    117. Populating Next Right Pointers in Each Node II
    116. Populating Next Right Pointers in Each Node
    DFS & BFS
    Binary Search
    博客保存
    python强大的正则表达式
    游戏注意的地方
    vim使用
    下一步的
    lua的动态特性
  • 原文地址:https://www.cnblogs.com/12jh23/p/6287085.html
Copyright © 2020-2023  润新知