javascript - submit() not working JS -


the javascript submit(); function not working. php script (hax.php) not return value, need ajax check has ran successfully. success method still work under condition or not validate script more. besides that, when else{} statement executed, still not submit form. know what's wrong?

<form action="validatelogin.php" method="post" autocomplete="off" id="loginform">         <input style="display:none" type="text" name="auto"/>         <input style="display:none" type="password" name="auto"/>         <label for="username">username: </label>         <input type="text" name="username" placeholder="your username" id="username" class="moderninput" style="padding: 5px; width:100%;"><br><br>         <label for="password">password:</label>         <input type="password" name="password" placeholder="your password" id="password" class="moderninput" style="padding: 5px; width:100%;">         <?php echo $_session["error"]; ?>         <input type="button" value="submit" class="btn btn-success btn-block" onclick="hackvalidate()">     </form>     <script>     function  _(str) {         return document.getelementbyid(str);     }     function hackvalidate() {         var username = _("username").value;         var password = _("password").value;         var regex = /select\s+|delete\s+|update\s+|--|=|/ig;         if (username.test(regex) || password.test(regex)) {             $.ajax({                 url: "hax.php",                 type: "post",                 data: {user: username, pass: password},                 success: function () {                     _("loginform").submit();                 }             });         } else {             _("loginform").submit();         }     } </script> 

switch order of .test() operands regexobj.test(str)

if (regex.test(username) || regex.test(password)) { 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -