我正在爲這個小項目提供比薩餅在線訂購服務。 (使用Spring Web MVC,Thymeleaf,...)html/Thymeleaf - 無線電輸入的實現
昨天,有人幫助我添加輸入以選擇特定的數量和大小。
<div>
<form th:action="@{/saveOrderAndReload(name=${pizza.name})}" method="post">
<div class="input-group">
<span class="input-group-addon">Bestellmenge (min. 1, max. 10):</span>
<input type="number" name="amount" class="form-control" min="1" max="10" placeholder="1"/>
</div>
<div class="input-group">
<input type="radio" name="size" value="1"> Klein</input>
<input type="radio" name="size" value="2"> Mittel</input>
<input type="radio" name="size" value="3"> Gross</input>
</div>
<div class="form-group">
<div class="form-group">
<input type="submit" class="btn btn-primary btn-success" value="zur Bestellung hinzufuegen"/>
</div>
</div>
</form>
「金額」欄免受虛假輸入應用程序本身,因爲它僅允許整數1-10,否則用戶得到一個通知,要求爲數字輸入。
無線電輸入您可以在其中3種尺寸之間選擇具有2個問題:
1)的按鈕themselfes之間的arent,它們彼此相鄰。 2)我不知道如何防止用戶不做任何輸入。
我環顧四周,很長一段時間發現了這個非標準的HTML版本:
<form>
<input type="radio" name="gender" value="male" checked> Male<br>
<input type="radio" name="gender" value="female"> Female<br>
<input type="radio" name="gender" value="other"> Other
</form>
而且是這樣的:
<ul>
<li th:each="ty : ${allTypes}">
<input type="radio" th:field="*{type}" th:value="${ty}" />
<label th:for="${#ids.prev('type')}" th:text="#{${'seedstarter.type.' + ty}}">Wireframe</label>
</li>
</ul>
我們沒有學到任何關於第二個的知識,所以我決定使用標準HTML。但我不想像這樣的例子工作:它會得到錯誤,這個「檢查」的表達式是不允許的,「
標籤沒有關閉」以及什麼。
所以我的問題是: 1)我能做些什麼來使輸入看起來更好? 2)我如何設置佔位符或標準值,以便應用程序始終獲取此輸入並且不會崩潰?
正如你可能已經意識到我對這種類型的東西,所以手下留情一個完整的初學者;)
我不知道,我不能使用縮寫形式,這是definitly問題。阿克西感謝您提供更多信息。 – Master1114