关于html里表单提交按钮没反应的问题

关于html里表单提交按钮没反应的问题,第1张

getElementById() 用来获取表上的控件ID。如果存在返回 ID,不存在返回undefind

if(isSame("txt_user_pass").value,"txt_user_pass_confirm").value),这句话可能有问题,大括号缺少一个,自己仔细检查下。

<form action="" onsubmit="return check_submit()">form代表表单,action我也不晓得是干毛的。onsubmit代表提交整个表单时触发某一个事件,存储过程。运行没反应参见上面那句IF判断。

input默认的控件就是 text类型,可以省略不写。其他类型,如BUTTON,RADIO,SELECT就必须写上TYPE=‘BUTTON’。

id='txt_user_name' 是控件的ID,在FORM表单里表是唯一存在的。不信你多写几个试试,肯定报错。规则的命名方法是 控件类型缩写+英文识别单词。txt代表文本框控件,user_name代表这个文本框是用来显示或者存储用户姓名的。

<!DOCTYPE html>

<html>

  <head>

        <meta http-equiv="Content-Type" content="text/html charset=UTF-8">

        <title>

            RunJS 演示代码

        </title>

        <style>

            *{

                margin:0

                outline:none

            }

            .wrap{

                margin:auto

                width:500px

                height:450px

                background-color:white

                border:1px solid gray

                border-radius:5px

            }

            table{

                width:100%

                border-collapse:collapse

                font:normal 13px '微软雅黑'

            }

            caption{

                font-size:20px

                color:rgb(158, 99, 99)

                padding:12px

            }

            td input[type=text]{

                border:1px solid rgb(46, 128, 216)

                border-radius:5px

                width:80%

                height:25px

            }

            tr{

                line-height:50px

            }

            td textarea{

                resize:none

                width:80%

                height:100px

                border:1px solid rgb(46, 128, 216)

                border-radius:5px

            }

            tr td:first-child{

                text-align:right

            }

            td input[type=submit],

            td input[type=reset]{

                background-color:rgb(52, 114, 143)

                color:white

                border:0

                width:75px

                height:25px

                border-radius:5px

                cursor:pointer

                margin:10px

            }

        </style>

        <script>

            var ck = function(form){

                var reg = /^\s+|\s+$/g

                if(form.zt.value.replace(reg, "") == ""){

                    alert("请输入主题")

                    form.zt.focus()

                    return false

                }else if(form.xq.value.replace(reg, "") == ""){

                    alert("请输入详细需求")

                    form.xq.focus()

                    return false

                }else if(form.sqr.value.replace(reg, "") == ""){

                    alert("输入申请人")

                    form.sqr.focus()

                    return false

                }else if(!/^1([38]\d|4[57]|5[0-35-9]|7[06-8])\d{8}$/.test(form.tel.value.replace(reg, ""))){

                    alert("联系电话不符规格")

                    form.tel.focus()

                    form.tel.select()

                    return false

                }else if(form.num.value.replace(reg, "") == ""){

                    alert("输入QQ/微信号")

                    form.num.focus()

                    return false

                }

                return true

            }

        </script>

  </head>

    <body>

        <form class="wrap" onsubmit="return ck(this)">

            <table>

                <caption>

                    定制申请

                </caption>

                <tr>

                    <td>

                        *主题:

                    </td>

                    <td>

                        <input type="text" name="zt" />

                    </td>

                </tr>

                <tr>

                    <td style="vertical-align:top">

                        *详细需求:

                    </td>

                    <td>

                        <textarea name="xq"></textarea>

                    </td>

                </tr>

                <tr>

                    <td>

                        *申请人:

                    </td>

                    <td>

                        <input type="text" name="sqr" />

                    </td>

                </tr>

                <tr>

                    <td>

                        *联系电话:

                    </td>

                    <td>

                        <input type="text" name="tel" />

                    </td>

                </tr>

                <tr>

                    <td>

                        *QQ/微信号:

                    </td>

                    <td>

                        <input type="text" name="num" />

                    </td>

                </tr>

                <tr>

                    <td colspan=2 style="text-align:center"> 

                        <input type="submit" value="提交" />

                        <input type="reset" value="重填" />

                    </td>

                </tr>

            </table>

        </form>

  </body>

</html>


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/6284768.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-19
下一篇 2023-03-19

发表评论

登录后才能评论

评论列表(0条)

保存