提交表单时无动作

时间:2014-03-16 05:33:37

标签: javascript html

我正在使用带有HTML和JavaScript的表单来检查输入。我做得很好,如果我输入一个号码,我会收到消息"仅限信件"。但是当我按下提交按钮时,它并没有给我操作页面(w.php)。

我想要它,这样当我按下登录按钮时,请带我到w.php页面。

这是我的代码:

<html>

<head>
<link rel="stylesheet" href="projectsite/include/validationEngine.jquery.css" />
<title>Projects Site</title>
</head>
<body background="se16.jpg">

<script>(function(d, s, id) {
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) return;
    js = d.createElement(s); js.id = id;
    js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
    fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));</script>

<form id="my_form" method="post" action="w.php">
<center>
<br>
<h1> <p style="color:brown;">  Login Page </p> </h1> 

<hr color="brown"> <br> 
<caption><h1><p style="color:black;">please Enter Username & Password</p></h1><caption>
<table border="3">

<tr><td><h2><p style="color:black;">Username: </p></td><td><input type="text"     name="username" class="validate[required,custom[onlyLetterSp]]" /></td><h2></tr>

<tr><td><h2><p style="color:black;">Password:</p> </td><td><input type="password" name="password" class="validate[required,custom[onlyLetterPa]]" /></td></h2></tr>


<tr><td></td><td><input type="submit" value="Log in" /></td></tr>

</table>
</center>
</form>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    <script src="projectsite/include/jquery.validationEngine.js"></script>
    <script src="projectsite/include/jquery.validationEngine-en.js"></script>
    <script>
        function ajaxValidationCallback(status, form, json, options) {

        if(status == true) {

                $(':input', '#my_form').not(':button, :submit, :reset, :hidden').val('').removeAttr('checked').removeAttr('selected');
                $("#message_sent").slideDown(400).delay(3000).slideUp(400);

          }
         }      
        $("#my_form").validationEngine({
            ajaxFormValidation : true,
            onAjaxFormComplete : ajaxValidationCallback,
            scroll : false
        }); 
    </script>
</body>
</html>

1 个答案:

答案 0 :(得分:1)

基于我可以研究的验证引擎,如果你去进行AJAX验证,提交表单的责任就在回调中。

link:https://github.com/posabsolute/jQuery-Validation-Engine/blob/master/demos/demoAjaxJAVA.html

// Called once the server replies to the ajax form validation request
function ajaxValidationCallback(status, form, json, options){
  if (console)
    console.log(status);

  if (status === true) {
    alert("the form is valid!");
    // uncomment these lines to submit the form to form.action
    // form.validationEngine('detach');
    // form.submit();
    // or you may use AJAX again to submit the data
  }
}