2014-01-28 22 views
-1

你好,出於某種原因,我的提交按鈕不起作用。我嘗試了幾種方法,我將在下面解釋。另外,我應該說我正在使用bootstrap模式。我不確定這是爲什麼它會以各種方式進行連線。提交無迴應

首先是我的表格:

<form name="register" action="register.php" method="post"> 
    <table id="registrationTable" border="0"> 
     <tr id="registrationTR"> 
      <td id="usernameTxt">Username:</td> 
      <td><input type="text" id="username" class="input" name="username" onChange"checkName(document)"> 
       <br /><p id="registrationInfo">Only alphanumeric, 6-characters minimum</p> 
      </td> 
      <td id="username_msg" style="color:red;"></td> 
     </tr> 
     <tr id="registrationTR"> 
      <td id="passwordTxt">Password:</td> 
      <td><input type="password" id="password" class="input" name="password" onChange"checkPassword(document)"> 
       <br /><p id="registrationInfo">6-characters minimum, case-sensitive</p> 
      </td> 
      <td id="pwd_msg" style="color:red;"></td> 
     </tr> 
     <tr id="registrationTR"> 
      <td>Confirm Password:</td> 
      <td><input type="password" id="rePassword" class="input" name="rePassword"> 
       <br \><p>&nbsp</p> 
      </td> 
     </tr> 
     <tr id="registrationTR"> 
      <td id="emailTxt">Email:</td> 
      <td><input type="text" id="email" class="input" name="email" onChange"checkEMail(document)"> 
       <br \><p>&nbsp</p> 
      </td> 
      <td id="email_msg" style="color:red;"></td> 
     </tr> 
    </table> 
</form> 

然後是我的提交按鈕。請注意我已經嘗試了兩種方式,一種是按鈕和一種輸入類型,它們都不起作用。是的,我已經拿出了輸入類型JS的驗證部分,看看它是否工作。

<input type="submit" class="btn btn-primary" name="registerSubmit" value="Submit" /> 

<button type="submit" class="btn btn-primary" name="registerSubmit" onClick="return validateInfo(document)">Register</button> 

JS代碼只是爲了驗證輸入字段中是否有任何輸入。最後,它返回true或false。我將只顯示最後一塊它返回true或false:

function validateInfo(document) { 
    if (checkName(document) && checkPassword(document) && checkRePassword(document) && checkEMail(document)) { 
     document.getElementById("register").submit(); 
     return true; 
    } 
    return false; 
} 

我甚至試圖用document.getElementById("register").submit();嘗試通過JS提交表單,但沒有奏效。

現在,它甚至不會加載php文件,所以我不會包含php文件atm。如果需要,我可以根據要求做到這一點。

任何幫助將是偉大的。

在此先感謝。

+3

寄存器形式的名稱不能形成ID –

+0

確保您的提交按鈕的形式 –

+0

內哪裏提交按鈕?我沒有在你的表格中看到它。 – Styphon

回答

0

你問的ID 「登記」,但你的形式不具有ID 「註冊」:

document.getElementById("register").submit();

試着給你的形式ID:

<form name="register" id="register" action="register.php" method="post"> 

如果它不起作用,請查看您的提交按鈕,如果它位於<form></form>塊內。

+0

非常感謝你對ID的建議。我多麼愚蠢,不記得它...... – fireboy0526