php – 不想刷新并保留最后插入的值

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了php – 不想刷新并保留最后插入的值脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_512_0@ 在我的htm页面中,我想使用一个按钮,通过使用函数提交我的表单.我在我的字段上使用验证,当我按下提交按钮时,它显示错误消息,但不保留最后一个值,它刷新我的表单.我只是希望我输入的值将存在于那里,只有只有错误消息的字段才会消失.所有其他领域仍然存在.
这是我的代码
<!DOCTYPE htML PubLIC "-//W3C//DTD XHTML 1.0 TransITional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <head>
    <!--<Meta http-equiv="refresh" content="text/html; charset=iso-8859-1" />-->
    <!--
    <Meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    -->
    <title>Phone Registration</title>
    <link rel="stylesheet" type="text/css" href="file:///C|/xampp/htdocs/track/css/view.css" media="all"/>
    <script type="text/javascript" src="file:///C|/xampp/htdocs/track/javascript/view.js"></script>
    <script type="text/javascript" src="file:///C|/xampp/htdocs/track/javascript/external.js"></script>
    <link rel="stylesheet" href="http://code.jquery.COM/ui/1.9.2/themes/base/jquery-ui.css" />
    <script src="http://code.jquery.com/jquery-1.8.3.js"></script>
    <script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>

    <script>
        $(function() {
            $( "#datepicker" ).datepicker();
        });
        </script>

    </head>
    <body id="main_body" >
        <img id="top" src="file:///C|/xampp/htdocs/track/images/top.png" alt=""/>
            <div id="form_container">
            <h3>
                <a href="file:///C|/xampp/htdocs/track/phonereg.PHP">Phone Registration</a>
                <a href="file:///C|/xampp/htdocs/track/officerreg.PHP">Officer Registration</a>
                <a href="file:///C|/xampp/htdocs/track/customerreg.PHP">Customer Registration</a>
                <a href="file:///C|/xampp/htdocs/track/taskentry.PHP">Task Entry</a>
            </h3>       
            <form  name="order" id="form_532698" class="appnitro"  method="post" action="" >
                <div class="form_description">
                <h2>Phone Registration</h2>
            </div>                      
            <ul >
              <li>
              <span>
                <label class="description">IMei # : </label>
                <input name="imei" id="imeinum" class="element text medium" type="text" maxlength="15" value=""/> 

                </span>
              </li>
              <li>
              <span>
                <label class="description" >Phone Number </label>
                <input name="phone" id="phnum" class="element text medium" type="text" maxlength="11" value="" onblur="validate(this)"/>  

                </span>
              </li>
              <li>
              <span>
                <label class="description" >From Date </label>
                <input id="datepicker" name="fdate" class="element text medium" maxlength="10" value="" type="text"/>
                </span>
              </li>
              <li>
              <span>
                <label class="description" for="element_4">Active </label>
                <input name="r1" id="rad" class="element radio" type="radio" value="Yes" checked="checked" />
                <label class="choice">Yes</label>
                <input name="r1" id="rad" class="element radio" type="radio" value="No" />
                <label class="choice">No</label>
                </span>
              </li>

              <li>
              <input type="button" name="save" value="Save" />
              </li>

              <!--
              <li class="buttons">
                    <input type="hidden" name="form_id" value="532698" />
                    <input class="button_text" type="submit" name="save" value="Save" id=""  />
                    &amp;nbsp;<input class="button_text" type="reset" name="cancel" value="Cancel" />
                    &nbsp;<input class="button_text" type="submit" name="seArch" value="Search" id="" />
                    &nbsp;<input class="button_text" type="submit" name="up" value="Update" id=""  />
                    &nbsp;<input class="button_text" type="submit" name="del" value="Delete" id="" />
              </li>
              -->
            </ul>
            </form>
    </div>
    <img id="bottom" src="file:///C|/xampp/htdocs/track/images/bottom.png" alt=""/>

    <script type="text/javascript" language="JavaScript">
//submit form
document.order.submit();
</script>
    </body>

</html>

请指导我,我该怎么做?我会感谢你的

如果验证失败,您可以使用此代码阻止表单提交到服务器
$("form").on("submit",function(event){
  if(!isValiDForm($(this)){
    event.preventDefault();
  }
});

假设isValidForm()方法接受表单选择器,如果表单有效则返回true,否则返回false.

脚本宝典总结

以上是脚本宝典为你收集整理的php – 不想刷新并保留最后插入的值全部内容,希望文章能够帮你解决php – 不想刷新并保留最后插入的值所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。