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>
  • 相关阅读:
    BeanFactory 工厂模式
    中小型企业架构
    数据状态图
    好文章
    leetcode 最受欢迎的91道题目
    windows下安装mysql8并修改密码
    leetcode 1049 Last Stone Weight II(最后一块石头的重量 II)
    leetcode 910. Smallest Range II
    leetcode 908. Smallest Range I
    leetcode 900. RLE Iterator
  • 原文地址:https://www.cnblogs.com/insane/p/12355426.html
Copyright © 2011-2022 走看看