html5表單及新增改良元素的示例分析-創(chuàng)新互聯(lián)

這篇文章主要介紹了html5表單及新增改良元素的示例分析,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。

成都創(chuàng)新互聯(lián)公司-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性價比達(dá)川網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式達(dá)川網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋達(dá)川地區(qū)。費(fèi)用合理售后完善,十載實(shí)體公司更值得信賴。

示例:

<!DOCTYPE html>    
<html>    
    <head>    
        <meta charset="UTF-8">    
        <title></title>    
    </head>    
    <body>    
        <!--表單內(nèi)元素的form屬性:為元素指定一個form屬性,屬性值為該表單的id-->  
        <form id="testform">    
            <input type="submit" />    
        </form>    
        <textarea form="testform"></textarea> <br /><hr />    
        <!--表單內(nèi)元素的formaction屬性:可以提交到不同頁面-->  
        <form id="form1" action="test.aspx">    
            <input type="submit" name="s1" value="內(nèi)部提交到test2" formaction="test2.aspx" />    
            <input type="submit"  />    
        </form>    
        <!--formmethod:可以為每個表單元素指定不同的提交方法-->  
        <form id="form2" action="test.aspx">    
            name:<input type="text" name="name" /><br />    
            <input type="submit" value="post方式提交"  formmethod="post"/>    
            <input type="submit" value="get方式提交"  formmethod="get"/>    
        </form><br/><hr />    
        <!--formenctype:可以指定不同的編碼方式-->  
        <form action="test2.aspx" method="post">    
            <input type="text" name="name" id="name" value="test" />    
            文件:<input type="file" name="files" />    
            <input type="submit"  value="上傳" formaction="test.aspx"  formenctype="multipart/form-data"/>    
            <input type="submit" value="提交" />    
        </form><br /><hr />    
        <!--formtarget:提交后再何處打開頁面-->  
        <form action="test.aspx">    
            <input type="submit" name="s1"  value="s1本頁打開" formaction="test2.aspx"  formtarget="_self"/>提交到test2    
            <input type="submit" name="s"  value="s新頁打開" formaction="test.aspx"  formtarget="_blank"/>提交到test    
        </form><hr />    
        <!--autofocus:自動獲得光標(biāo)焦點(diǎn)-->  
        <input type="text" autofocus /><br />    
        <!--control:通過該屬性來訪問該表單元素-->  
        <form >    
            <label id="label">    
            郵編:<input id="txtzip" maxlength="6" /><small>請輸入6位數(shù)字</small>    
            </label>    
            <input type="button" value="設(shè)置默認(rèn)值" onclick="setValue()" />    
        </form>    
        <!--placeholder:未輸入狀態(tài)的輸入提示-->  
        <input type="text" placeholder="請輸入內(nèi)容" /><br />    
        <!--list:單行文本框的list屬性,屬性值為datalist的id。    autocomplete:自動完成-->  
        list屬性:<input type="text" list="mylist" autocomplete="on"/>    
        <datalist id="mylist" >    
            <option value="第一">第一</option>    
            <option value="第二">第二</option>    
            <option value="第三">三</option>    
        </datalist><br />    
        <!--pattern:設(shè)置正則表達(dá)式驗(yàn)證-->  
        <form>    
        輸入一個字母與三個大寫字母:<input type="text" pattern="[0-9][A-Z]{3}"  required=""/>    
        <input type="submit" />    
        </form><br />    
        <!--indeterminate:說明復(fù)選框處于尚未明確是否選取狀態(tài)-->  
        <input type="checkbox" indeterminate id="cb" />indeterminate<br />    
        <!--image的height和width設(shè)置圖片高寬-->  
        設(shè)置圖片寬高:<input type="image" src="img/webp.jpg" alt="編輯" width="23" height="23" /><br />    
        <!--textarea:maxlength和wrap屬性:hard換行也要指定cols,soft不換行-->  
        <form action="test.aspx" method="post">    
            <textarea name="name" maxlength="10" rows="5" cols="5" wrap="hard"></textarea>    
            <input type="submit" value="提交" />    
        </form><br />    
     <!--url類型:只能提交url地址格式-->  
        url:<input type="url" name="url"  required=""/><input type="submit" /><br />    
        email:<input type="email" name="email" required=""/><input type="submit" /><br />    
        date(谷歌瀏覽器):<input type="date" name="date"  /><br />    
        time(谷歌瀏覽器):<input type="time" name="time" /><br />    
        datetime-local:<input type="datetime-local" name="datetime"  value="2016-05-26T22:31:30"/><br />    
        <!--日期時間類型的step屬性:單擊調(diào)整時對選擇值多大限定-->  
        step:<input type="date" step="3" /><br /><hr />    
        number:<input type="number"  value="25" min="10" min="20" max="30" step="2"  /><br />    
        range:<input type="range" value="25" min="10" max="100" step="5" /><br />    
        search:<input type="search"/><br />    
        tel:<input type="tel"  /><br />    
        color:<input type="color" /><br />    
        <hr />    
        output元素的追加:    
        <form id="testform">    
            請選擇一個值:<input type="range" id="range" min="5" max="100" step="5" value="10" onchange="out();"/>    
            <output id="out">10</output>    
        </form>    
    </body>    
</html>    
<script type="text/javascript">    
    function setValue(){    
        var lable=document.getElementById("label");    
        var txtbox=lable.control;//通過control該屬性來訪問該表單元素    
        txtbox.value="213001";    
    }    
    //indeterminate測試設(shè)置為true    
    var cb=document.getElementById("cb");    
    cb.indeterminate=true;    
    //選擇的值output輸出    
    function out(){    
        Debug;    
        var number=document.getElementById("range").value;    
        document.getElementById("out").value=number;    
    }    
</script>

感謝你能夠認(rèn)真閱讀完這篇文章,希望小編分享的“html5表單及新增改良元素的示例分析”這篇文章對大家有幫助,同時也希望大家多多支持創(chuàng)新互聯(lián)網(wǎng)站建設(shè)公司,,關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,更多相關(guān)知識等著你來學(xué)習(xí)!

網(wǎng)頁標(biāo)題:html5表單及新增改良元素的示例分析-創(chuàng)新互聯(lián)
網(wǎng)頁鏈接:http://muchs.cn/article20/cochco.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信小程序、全網(wǎng)營銷推廣、品牌網(wǎng)站設(shè)計網(wǎng)站營銷、軟件開發(fā)、標(biāo)簽優(yōu)化

廣告

聲明:本網(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)

成都網(wǎng)站建設(shè)