2014-09-03 63 views
0

我正在使用引導程序註冊頁面我正在使用http://bootstrapvalidator.com/插件來驗證我的表單。所有驗證完成,但當我點擊提交按鈕時,它得到禁用和數據不會發送到下一個PHP文件,請幫助我,我的代碼如下。 HTML代碼在bootstrap3中點擊時提交按鈕被禁用,並且數據沒有被髮送到數據庫

<!DOCTYPE html> 
<html> 
<head> 
    <link rel="stylesheet" href="bootstrap/css/bootstrap.css"/> 
    <link rel="stylesheet" href="bootstrap/css/bootstrapValidator.min.css"/> 
    <script type="text/javascript" src="bootstrap/js/jquery-1.10.2.min.js"></script> 
    <script type="text/javascript" src="bootstrap/js/bootstrap.min.js"></script> 
    <!-- Either use the compressed version (recommended in the production site) --> 
    <script type="text/javascript" src="bootstrap/js/bootstrapValidator.min.js"></script> 
<script type="text/javascript"> 

$(document).ready(function() { 
$('#signupbox').bootstrapValidator({ 
live: 'enabled', 
    message: 'This value is not valid', 
    feedbackIcons: { 
     valid: 'glyphicon glyphicon-ok', 
     invalid: 'glyphicon glyphicon-remove', 
     validating: 'glyphicon glyphicon-refresh' 
    }, 
    fields: { 
     firstName: { 
      validators: { 
       notEmpty: { 
        message: ' ' 
       }, 
       stringLength: { 
        min: 2, 
        max: 30, 
        message: ' ' 
       }, 
       regexp: { 
        regexp: /^[a-zA-Z ]+$/, 
        message: ' ' 
       } 
      } 
     }, 
     lastName: { 
      validators: { 
       notEmpty: { 
        message: ' ' 
       }, 
       stringLength: { 
        min: 3, 
        max: 30, 
        message: ' ' 
       }, 
       regexp: { 
        regexp: /^[a-zA-Z ]+$/, 
        message: ' ' 
       } 
      } 
     }, 

     email: { 
      validators: { 
      notEmpty: { 
        message: ' ' 
       }, 
       emailAddress: { 
        message: 'The input is not a valid email address' 
       }, 
       regexp: { 
        regexp: /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i, 
        message: ' ' 
       } 
      } 
     }, 
     password: { 
      validators: { 
       notEmpty: { 
        message: 'The password is required and cannot be empty' 
       }, 


      } 
     }, 
     confirmPassword: { 
      validators: { 
       notEmpty: { 
        message: 'The confirm password is required and cannot be empty' 
       }, 
       identical: { 
        field: 'password', 
        message: ' ' 
       } 

      } 
     } 


    } 

}); 

// Validate the form manually 
}); 


</script> 



</head> 

<body> 



    <div id="signupbox" style="margin-top:50px;" class="mainbox col-md-4 col-md-offset-4 col-sm-1 col-sm-offset-3"> 
       <div class="panel panel-info"> 
        <div class="panel-heading"> 
         <div class="panel-title">Sign Up</div> 
         <div style="float:right; font-size: 85%; position: relative; top:-15px"><a id="signinlink" href="login.php">Sign In</a></div> 
        </div> 
        <div class="panel-body" > 
         <form id="signupform" class="form-horizontal" action="submit.php" method="GET" role="form" > 

          <div id="signupalert" style="display:none" class="alert alert-danger"> 
           <p>Error:</p> 
           <span></span> 
          </div> 

          <div class="form-group"> 

         <div class="col-lg-6"> 
          <input type="text" class="form-control" name="firstName" placeholder="First name" /> 
         </div> 
         <div class="col-lg-6"> 
          <input type="text" class="form-control" name="lastName" placeholder="Last name" /> 
         </div> 
        </div> 





          <div class="form-group has-feedback"> 

           <div class="col-md-12"> 
            <input type="text" class="form-control" name="email" placeholder="Email Address"> 
           </div> 
          </div> 

          <div class="form-group"> 

           <div class="col-md-12"> 
            <input type="date" class="form-control" name="bday" placeholder="Date of Birth"> 
           </div> 
          </div> 

          <div class="form-group"> 
           <div class="col-md-12"> 
            <input type="password" class="form-control" name="password" placeholder="Password"> 
           </div> 
          </div> 

           <div class="form-group"> 
           <div class="col-md-12"> 
            <input type="password" class="form-control" name="confirmPassword" placeholder="Confirm Password"> 
           </div> 
          </div> 




          <div class="form-group"> 
           <!-- Button -->           
           <div class="col-md-offset-0 col-md-9"> 
            <input type="submit" id="submit" style="float:left;" class="btn btn-info" value="Signup"> 


           </div> 
          </div> 





         </form> 
        </div> 
       </div> 




    </div> 




</body> 

回答

0

在表單頁面您使用method="GET"方法來傳遞數據。

<form id="signupform" class="form-horizontal" action="submit.php" method="GET" role="form" > 

嘗試使用method="POST"並查看其是否正常工作。

<form id="signupform" class="form-horizontal" action="submit.php" method="POST" role="form" > 
+0

我試過但沒有工作,, – 2014-09-04 03:16:58

+0

@ALiiRaja你試過我的解決方案嗎? – Arkni 2014-09-16 19:34:01

0

你的問題是,你正在使用提交爲ID提交按鈕。

例如,你不能提交表單驗證後,如果使用提交的ID或命名提交按鈕:

<button type="submit" name="submit" class="btn btn-primary">Submit</button> 

或者

<button type="submit" id="submit" class="btn btn-primary">Submit</button> 

改變你的提交按鈕的ID的東西否則會解決這個問題。

請參閱the name conflict warning的官方文檔。

相關問題