dongtu1789 2014-10-16 06:17
浏览 59

如何在网址中使用HTML验证并获取没有电子邮件和密码的ajax响应

I have a login form that collects the user's e-mail and password. I send that through AJAX to be validated on the server side. AJAX sends back a response to indicate whether the login succeeded or that the user needs to register first or that the login failed and the user has x number of attempts left before the system will block their login attempts for a period of time. I am successful in this including the prevention of the e-mail and password showing up in the browser's URL address line. I believe I succeeded in this by using e.preventDefault() in the jQuery script that processes the click of the submit button.

When I use the preventDefault() function, it also prevents HTML validation of data on the client side. I like its immediate and sufficient validation to indicate problems such as when a user hasn't even entered data in a field before submission. Furthermore, the HTML validation is more helpful than an alter by indicating exactly which input field has failed its validation. I do additional validation both on the client and server sides.

I want both features: 1) HTML validation feedback before the AJAX verification; 2) No email or password showing in the URL address line for God and Country to see.

I have searched for solutions, but it is possible that the HTML validation is still new enough and not that sufficient for true validation that many developers are not trying to achieve the goal I have stated here. Therefore, I could not find information that addressed this set of issues simultaneously. I would really appreciate feedback about how to achieve this in the manner I am trying to do or suggested other approaches that achieve the same user-friendly ends I intend. Here is the jQuery code I am using when the user clicks the Submit button.

            // Main log in
            $("#login_button").click(function(e) {
                e.preventDefault();
                var email = $('#login_email').val();
                var password = $('#login_password').val();
                $.post('inner_pages/login_processing.php', {'login_email':email, 'login_password':password}, function(data) { //make ajax call to check_email.php
                    alert(data);
                });
            }); // End of log in
  • 写回答

1条回答 默认 最新

  • douzhantao2857 2014-10-16 07:03
    关注

    I have no idea about the HTML Validation but you could remove the e-mail and password in the URL by:

    window.location.hash = '';

    评论

报告相同问题?

悬赏问题

  • ¥15 51单片机中C语言怎么做到下面类似的功能的函数(相关搜索:c语言)
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程