玩轉html5(三)---智能表單(form),使排版更加方便

來源:互聯網
上載者:User

標籤:style   blog   http   color   使用   ar   for   div   sp   

<!DOCTYPE html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>form表單學習筆記</title></head><body>    <!-- 在舊版的html中,form表單與input等元素必須嵌套使用,為了排版方便,在html中提出了新方法          表單的多個內容不必非得放到一塊,為前台美工提供了非常大的方便-->          <!-- 首先建立一個form表單,給其定義一個id -->          <form id="regForm">             郵箱 :<input type="email" name="user_email" autofocus="autofocus"/>          </form>          <!-- 然後定義一個其它標籤,比方input,submit,關聯這個id -->          username:<input name="name" type="text" form="regForm"/>                  <input type="submit" form="regForm"/>          <!-- 點擊button時,按預設提交,能夠在地址欄看到提交資訊 -->    <!--  關於html5新增的一些input屬性,在我的還有一篇文章這樣的專門講過,給大家個連結,在這裡就不在贅述了。 -->          http://blog.csdn.net/u012116457/article/details/24577509    <!-- 下來講一下新增的表單屬性   -->          1.屬性:required  值:required  表單擁有該屬性工作表示內容不可為空,為必填項              <input name="name" type="password" required="required" form="regForm"/>              2.屬性:placeholder 值:提示文本  表單的提示資訊,若存在預設值則不顯示              <!-- 講這個屬性有必要先搞明確舊版本號碼中是怎麼提示預設值的,舊版本號碼使用的是value屬性 -->                  username:<input type="text" name="name" value="預設值" form="regForm"/>              <!-- 當點擊提交時,若使用者不正確其進行改動,會把“預設值”這三個字也傳向後台,而我們往往不須要,              html5為我們提供的這個新屬性,假設使用者不正確預設值進行改動,其內容將不會被提交 -->                  username:<input type="text" name="name" placeholder="預設值" form="regForm"/>              <!-- 在表現形式上也有所改變,大家能夠自己試試 -->          3.屬性:autofocus 值:autofocus    自己主動聚焦屬性,頁面載入完畢後游標會自己主動聚焦到指定表單                  username:<input type="text" name="name" autofocus="autofocus" form="regForm"/>                  重新整理頁面後,游標會自己主動聚焦到該文字框中          4.屬性:Pattern 值:正則表達式   輸入的內容必須匹配到指定正則                <!-- 在以往的html中使用正則須要寫到js等裡邊,html5中能夠直接使用正則表達式,在html中就能夠直接推斷,                是不是省了好多事情呢? -->                <!-- 以下這個範例中正則的意思是僅僅能輸入8位元字,在前台頁面,若不符合規則,會提示格式不正確 -->                  學號:<input type="text" name="num" Pattern="\d{8}"/></body></html>


請珍惜小編勞動成果,該文章為小編原創,轉載請註明出處。

玩轉html5(三)---智能表單(form),使排版更加方便

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.