CSS表單屬性

來源:互聯網
上載者:User

標籤:required   index   擷取   focus   code   多檔案   element   class   com   

一般來說,表單在一個頁面中是必不可少的,下面是我對錶單的知識總結:

  依次要說的是表單元素、表單屬性、以及表單提交(js知識)

1,表單元素:

  <form action="提交的位置 //不寫的話會提交給自身" method="如何發送表單資料"></form>

 form內的元素:

  1)datalist(資料列表)

  2)keygen(產生加密字串)

  3)output(輸出結果)

  4)meter(度量器)

2,表單屬性:  

  1)palceholder:請輸入使用者名稱 當使用者輸入文字後,placeholder內的內容將會消失

  2)autofocus:自動獲得焦點

  3)multiple:多檔案傳輸,在file中使用

  4)autocomplete="on":自動補充剩餘內容

  5)novalidate:關閉驗證

  6)required:必填項

  7)pattern:自訂驗證  (pattern="\d")要求輸入數字,大寫D為除數字以外的

3,表單提交驗證:

  onsubmit="return 函數()"

 程式碼範例:

    function checkForm(){        //擷取email的value值        var email = document.getElementById("email").value;        if(email == ""){            return false;        }else if(email.indexOf("@")==-1){            return false;        }else{            return true;        }    }

注意:如果既要驗證賬戶,又要驗證密碼,則需要最後再寫 retrun true;

 

CSS表單屬性

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.