zoukankan      html  css  js  c++  java
  • 当页面提交时,执行相关JS函数检查输入是否合法

    当页面提交时,执行相关JS函数检查输入是否合法

    关键代码

    <form action="tj.php" method="post" onSubmit="return check()" name="free">

    完整页面代码

    <html>
        <head>
            <title>工作记录</title>
            <script LANGUAGE="javascript">
            function check()
            {
                if(document.free.date.value.length==0){
                alert("时间不能为空!");
                document.free.date.focus();
                return false;
                }
                if(document.free.addr.value.length==0){
                alert("地址不能为空!");
                document.free.addr.focus();
                return false;
                }
                if(document.free.content.value.length==0){
                alert("内容不能为空!");
                document.free.content.select();
                return false;
                }
    
            }
            </script>
        </head>
        
        <body>
        <div align="center">
            <h4>添加工作记录</h4>
            <form action="tj.php" method="post" onSubmit="return check()" name="free">
            <table border="0">
                <tr>
                    <td>时间:</td>    <td><input type="text" name="date" value="<?php echo date('Y-m-d');?>" /></td>    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td>地点:</td>    <td><input type="text" name="addr" onMouseOver="this.focus()" /></td>    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td>手机:</td>    <td><input type="text" name="tel" /></td>    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td>内容:</td>    <td><input type="text" name="content" /></td>    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td>备注:</td>    <td><input type="text" name="ps" /></td>    <td>&nbsp;</td>
                </tr>
            </table>
            <input type="submit" value="提交"/><input type="reset" value="清空"/>
            </form>
        </div>
        <body>
    </html>
  • 相关阅读:
    结果偏见 (行为经济学)
    天下没有免费的午餐
    双环学习
    信息对称、网络效应
    为什么说盲维是认知升级的重要概念?
    给思维找一个支点
    风险是一种商品
    认知方法论第一课
    A*算法深入
    A*算法入门
  • 原文地址:https://www.cnblogs.com/insane/p/12355426.html
Copyright © 2011-2022 走看看