Skip to Content
MOBILE HTML5學習手冊
book

MOBILE HTML5學習手冊

by Estelle Weyl
June 2014
Intermediate to advanced
488 pages
9h 56m
Chinese
GoTop Information, Inc.
Content preview from MOBILE HTML5學習手冊
HTML5 Web 表單
|
85
<input> 的屬性(及其他表單元素)
在深入探討舊與新的輸入類型之前,你應該先瞭解
<input>
元素的新與舊屬性。
type 屬性
我們剛才提過唯一必要的輸入屬性:
type
屬性。雖然它是必要的,但如果你將它省略的
話仍然可以動作,它的預設值為
type="text"
<label>Phone: <input type="tel" name="phone"></label>
<label>Website: <input type="url" name="website"></label>
HTML5 中,
type
屬性有 23 種可用的值,第 94 頁的“<input> 類型與屬性”會討論
它們。請注意,如果瀏覽器不支援某種新的輸入類型,這個類型就會被設成預設的
text
類型。這些新類型都是增強的效果,如果瀏覽器不瞭解新類型,表單仍然可以被存取,
所以不需要等到瀏覽器完整支援之後,才開始實作新的輸入類型。
required 屬性
若要將某個表單欄位標記為必要的,可使用
required
屬性。當使用者試著提交一個表
單時,如果有一個必要的表單欄位是空白的,或是它的值是無效,這個表單就不會被提
交,而且聚焦會移到第一個無效的表單元素。支援的瀏覽器會提供一個錯誤訊息給使用
者,例如在空白時顯示“你必須填入一個數值”或在格式錯誤時顯示“12-12 是不符合
網頁要求的格式”(
pattern
屬性將在第 89 頁說明),或其他類似的訊息。
除了
buttons
range
color
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

JAVASCRIPT網頁應用程式設計

JAVASCRIPT網頁應用程式設計

Alex MacCaw

Publisher Resources

ISBN: 9789863471240