2013-07-03 06:02
浏览 28


I want to run a php script each time the input value of the <input type="text">changes, for like checking if the passwords in a registration form are the same

图片转代码服务由CSDN问答提供 功能建议

我想在每次&lt; input type =“text的输入值时运行php脚本 “&gt; 更改,以便检查注册表单中的密码是否相同

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

4条回答 默认 最新

  • dsfsdfsdfsdf6455 2013-07-03 06:05

    PHP is server side scripting language, so when you submit the form then it will check the value of both textboxes..

    Instead of PHP you can use JavaScript or jQuery or AJAX to check the value of both text box.

    点赞 评论
  • doujiebo9849 2013-07-03 06:12

    PHP is a server side language, and its work is finish once the processing completes and the HTML is thrown out to the browser. It can only only responds to user actions if a new server side request is generated for every user inout.

    Where as javascript is the client side language, which can interact with the user and server both.

    Now if you want to hit on the server, on every user input in the text box, then you have to do it using javascript, which indirectly send a ajax call to the server to get its response, and to do the required changes.

    点赞 评论
  • duanci1939 2013-07-03 06:52

    Another good option (especially if you do your processing on the same page) would be to simply check the field when the user submits it.

    If it meets the required standards let it pass, otherwise just repopulate the fields with the data that was submitted, and produce some error text next to the field(s) that need it.

    Its not as "pretty" as an AJAX solution, but its almost as convenient and is very easy to do in PHP.

    点赞 评论
  • dongyao4419 2013-07-03 07:30
    <form  method="POST" onsubmit="return check()"> 
     <input type="password" name="pass" id="pass" onchange="check(this)>
     <input type="password" name="pass1" id="pass1" onchange="check(this)>

    and than javascript

     function check()
      var pass = document.getElementById('pass').value;
      var pass1 = document.getElementById('pass1').value;
       if(pass1 != pass)
         alert("Pass don't macth");
         return false;

    maybe something like that?

    点赞 评论

相关推荐 更多相似问题