我想阻止時的用戶名字段爲空提交操作,並顯示在ID爲「ERR_MSG」的div一定的警示作用停止提交操作
<!-- Main jumbotron for a primary marketing message or call to action -->
<div class="jumbotron">
<div class="container">
<h1>Register</h1>
<form role="form" method="post">
<div id="data-text">
<input type="text" name="nick" placeholder="Nick" class="form-control" style="width: 250px;">
<input type="text" name="name" placeholder="Imię" class="form-control" style="width: 250px;">
<input type="text" name="surname" placeholder="Nazwisko" class="form-control" style="width: 250px;">
<input type="text" name="email" placeholder="Email" class="form-control" style="width: 250px;">
<input type="text" name="phone" placeholder="Telefon" class="form-control" style="width: 250px;">
<input type="text" name="password" placeholder="Hasło" class="form-control" style="width: 250px;">
<input type="text" name="repassword" placeholder="Powtórz hasło" class="form-control" style="width: 250px;">
</div>
<button type="submit" name='Proceed' value='register' class="btn btn-success">Zarejestruj</button>
</form>
<div id="err_msg"></div>
</div>
</div>
的問題是,提交表單刷新頁面,並重置每個元素到它的默認值
我應該處理每一個領域與JS,然後用一個jQuery發佈數據?我不喜歡可能的矯枉過正解決方案
JavaScript是這裏的答案。 – 2015-02-24 09:57:22
您需要javascript和/或'$ _POST'值才能填寫默認值(如果存在)。或者'需要',見下文。 – jeroen 2015-02-24 09:58:08
你可以使用javasript,如果使用html5,你可以使用require屬性。 – lmarcelocc 2015-02-24 09:58:28