2014-04-09 55 views
1

所以我有一个表单有两个字段,其中一个字段需要有信息才能成功显示下一页。我将如何禁用提交按钮,直到该字段中有一些文本?禁用提交按钮,直到字段有文本?

这里是HTML代码;

<div id="content"> 

    <form action="avatarquery.php" method="POST" id="login-form"> 

     <fieldset> 

      <p> 
       <label for="login-username">Server Name:</label> 
       <input type="text" id="login-username" name="name" class="round full-width-input" autofocus /> 
      </p> 

      <p> 
       <label for="login-password">Server IP:</label> 
       <input type="text" id="login-password" name="ip" class="round full-width-input" /> 
      </p> 

      <input class="button round blue image-right ic-right-arrow" type="submit" id="register" /> 


     </fieldset> 

     <br/><div class="information-box round">Please Note: Some servers may not work due to their Configs not having Query Enabled.</div> 

    </form> 
+1

您将需要使用JavaScript有提交按钮“启用”。但是,HTML5引入了“required”属性,可以帮助您。 – George

+0

谢谢!我忘了HTML5需要:) – Cwtch22

回答

2

如果必须使用HTML来完成,然后在HTML5中,你可以使用

<input type="text" required /> 

否则在JavaScript中,你可以尝试的属性设置为输入按钮。

直到值为“”,您可以设置该属性

<input type="submit" disabled /> 
+0

谢谢!我忘了HTML5的功能:) – Cwtch22

相关问题