這篇“HTML5表單有什么屬性”文章,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們一定要參考一下,對于“HTML5表單有什么屬性”,小編整理了以下知識點(diǎn),請大家跟著小編的步伐一步一步的慢慢理解,接下來就讓我們進(jìn)入主題吧。
1、簡易性:超級文本標(biāo)記語言版本升級采用超集方式,從而更加靈活方便,適合初學(xué)前端開發(fā)者使用。 2、可擴(kuò)展性:超級文本標(biāo)記語言的廣泛應(yīng)用帶來了加強(qiáng)功能,增加標(biāo)識符等要求,超級文本標(biāo)記語言采取子類元素的方式,為系統(tǒng)擴(kuò)展帶來保證。 3、平臺無關(guān)性:超級文本標(biāo)記語言能夠在廣泛的平臺上使用,這也是萬維網(wǎng)盛行的一個原因。 4、通用性:HTML是網(wǎng)絡(luò)的通用語言,它允許網(wǎng)頁制作人建立文本與圖片相結(jié)合的復(fù)雜頁面,這些頁面可以被網(wǎng)上任何其他人瀏覽到,無論使用的是什么類型的電腦或?yàn)g覽器。
HTML5新的表單屬性主要在兩個方面<form><input>元素的新屬性。
HTML5表單的屬性
新的form屬性:
autocomplete
novalidate
新的input屬性:
autocomplete
autofocus
form
form overrides (formaction, formenctype, formmethod, formnovalidate, formtarget)
height和width
list
min,max和step
multiple
pattern(regexp)
placeholder
required
autocomplete 屬性
autocomplete 屬性規(guī)定 form 或 input 域應(yīng)該擁有自動完成功能。
注:autocomplete 適用于 <form> 標(biāo)簽,以及以下類型的 <input> 標(biāo)簽:text, search, url, telephone, email, password, datepickers, range 以及 color。
當(dāng)用戶在自動完成域中開始輸入時,瀏覽器應(yīng)該在該域中顯示填寫的選項(xiàng):
<form action="demo_form.asp" method="get" autocomplete="on"> First name: <input type="text" name="fname" /><br /> Last name: <input type="text" name="lname" /><br /> E-mail: <input type="email" name="email" autocomplete="off" /><br /> <input type="submit" /> </form>
注:在某些瀏覽器中,您可能需要啟用自動完成功能,以使該屬性生效。
autofocus 屬性
autofocus 屬性規(guī)定在頁面加載時,域自動地獲得焦點(diǎn)。
注:autofocus 屬性適用于所有 <input> 標(biāo)簽的類型。
User name: <input type="text" name="user_name" autofocus="autofocus" />
form 屬性
form 屬性規(guī)定輸入域所屬的一個或多個表單。
注:form 屬性適用于所有 <input> 標(biāo)簽的類型。
form 屬性必須引用所屬表單的 id:
<form action="demo_form.asp" method="get" id="user_form"> First name:<input type="text" name="fname" /> <input type="submit" /> </form> Last name: <input type="text" name="lname" form="user_form" />
注:如需引用一個以上的表單,請使用空格分隔的列表。
表單重寫屬性
表單重寫屬性(form override attributes)允許您重寫 form 元素的某些屬性設(shè)定。
表單重寫屬性有:
formaction - 重寫表單的 action 屬性
formenctype - 重寫表單的 enctype 屬性
formmethod - 重寫表單的 method 屬性
formnovalidate - 重寫表單的 novalidate 屬性
formtarget - 重寫表單的 target 屬性
注:表單重寫屬性適用于以下類型的 <input> 標(biāo)簽:submit 和 image。
<form action="demo_form.asp" method="get" id="user_form"> E-mail: <input type="email" name="userid" /><br /> <input type="submit" value="Submit" /> <br /> <input type="submit" formaction="demo_admin.asp" value="Submit as admin" /> <br /> <input type="submit" formnovalidate="true" value="Submit without validation" /> <br /> </form>
注:這些屬性對于創(chuàng)建不同的提交按鈕很有幫助。
height 和 width 屬性
height 和 width 屬性規(guī)定用于 image 類型的 input 標(biāo)簽的圖像高度和寬度。
注:height 和 width 屬性只適用于 image 類型的 <input> 標(biāo)簽。
<input type="image" src="img_submit.gif" width="99" height="99" />
list 屬性
list 屬性規(guī)定輸入域的 datalist。datalist 是輸入域的選項(xiàng)列表。
注:list 屬性適用于以下類型的 <input> 標(biāo)簽:text, search, url, telephone, email, date pickers, number, range 以及 color。
Webpage: <input type="url" list="url_list" name="link" /> <datalist id="url_list"> <option label="W3Schools" value="http://www.w3school.com.cn" /> <option label="Google" value="http://www.google.com" /> <option label="Microsoft" value="http://www.microsoft.com" /> </datalist>
min、max 和 step 屬性
min、max 和 step 屬性用于為包含數(shù)字或日期的 input 類型規(guī)定限定(約束)。
max 屬性規(guī)定輸入域所允許的大值。
min 屬性規(guī)定輸入域所允許的最小值。
step 屬性為輸入域規(guī)定合法的數(shù)字間隔(如果 step="3",則合法的數(shù)是 -3,0,3,6 等)。
注:min、max 和 step 屬性適用于以下類型的 <input> 標(biāo)簽:date pickers、number 以及 range。
下面的例子顯示一個數(shù)字域,該域接受介于 0 到 10 之間的值,且步進(jìn)為 3(即合法的值為 0、3、6 和 9):
Points: <input type="number" name="points" min="0" max="10" step="3" />
multiple 屬性
multiple 屬性規(guī)定輸入域中可選擇多個值。
注:multiple 屬性適用于以下類型的 <input> 標(biāo)簽:email 和 file。
Select images: <input type="file" name="img" multiple="multiple" />
novalidate 屬性
novalidate 屬性規(guī)定在提交表單時不應(yīng)該驗(yàn)證 form 或 input 域。
注:novalidate 屬性適用于 <form> 以及以下類型的 <input> 標(biāo)簽:text, search, url, telephone, email, password, date pickers, range 以及 color.
<form action="demo_form.asp" method="get" novalidate="true"> E-mail: <input type="email" name="user_email" /> <input type="submit" /> </form>
pattern 屬性
pattern 屬性規(guī)定用于驗(yàn)證 input 域的模式(pattern)。
模式(pattern) 是正則表達(dá)式。您可以在我們的 JavaScript 教程中學(xué)習(xí)到有關(guān)正則表達(dá)式的內(nèi)容。
注:pattern 屬性適用于以下類型的 <input> 標(biāo)簽:text, search, url, telephone, email 以及 password。
下面的例子顯示了一個只能包含三個字母的文本域(不含數(shù)字及特殊字符):
Country code: <input type="text" name="country_code" pattern="[A-z]{3}" title="Three letter country code" />
placeholder 屬性
placeholder 屬性提供一種提示(hint),描述輸入域所期待的值。
注:placeholder 屬性適用于以下類型的 <input> 標(biāo)簽:text, search, url, telephone, email 以及 password。
提示(hint)會在輸入域?yàn)榭諘r顯示出現(xiàn),會在輸入域獲得焦點(diǎn)時消失:
<input type="search" name="user_search" placeholder="Search php" />
required 屬性
required 屬性規(guī)定必須在提交之前填寫輸入域(不能為空)。
注:required 屬性適用于以下類型的 <input> 標(biāo)簽:text, search, url, telephone, email, password, date pickers, number, checkbox, radio 以及 file。
Name: <input type="text" name="usr_name" required="required" />
以上是“HTML5表單有什么屬性”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學(xué)習(xí)更多知識,歡迎關(guān)注創(chuàng)新互聯(lián)成都網(wǎng)站設(shè)計(jì)公司行業(yè)資訊頻道!
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點(diǎn)與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。
當(dāng)前文章:HTML5表單有什么屬性-創(chuàng)新互聯(lián)
當(dāng)前路徑:http://chinadenli.net/article48/djjihp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供小程序開發(fā)、網(wǎng)頁設(shè)計(jì)公司、外貿(mào)建站、做網(wǎng)站、網(wǎng)站導(dǎo)航、網(wǎng)站制作
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容