<form id="hz9zz"></form>
  • <form id="hz9zz"></form>

      <nobr id="hz9zz"></nobr>

      <form id="hz9zz"></form>

    1. 明輝手游網中心:是一個免費提供流行視頻軟件教程、在線學習分享的學習平臺!

      html中如何控制input輸入格式的示例

      [摘要]只能輸入中文<input type="text" onkeyup="this.value=this.value.replace(/[^\u4e00-\u9fa5]/g,)">只能輸入英文<input type="text"...

      只能輸入中文

      <input type="text" onkeyup="this.value=this.value.replace(/[^\u4e00-\u9fa5]/g,'')">

      只能輸入英文

      <input type="text" onkeyup="this.value=this.value.replace(/[^a-zA-Z]/g,'')">

      文本框只能輸入數字代碼(小數點也不能輸入)

      <input onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')">

      只能輸入數字,能輸小數點

      方法一:<input onkeyup="if(isNaN(value))execCommand('undo')" onafterpaste="if(isNaN(value))execCommand('undo')">  
      方法二:<input name=txt1 onchange="if(/\D/.test(this.value)){alert('只能輸入數字');this.value='';}">  
      方法三:<input onkeyup="this.value=this.value.replace(/[^\d.]/g,'')" onafterpaste="this.value=this.value.replace(/[^\d.]/g,'')" >

      只能輸入數字和英文

      <input onKeyUp="value=value.replace(/[^\d chun]/g,'')">

      只能輸入字母和中文

      <input onkeyup="value=value.replace(/[\d]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[\d]/g,''))"   
       maxlength=10 name="Numbers">

      只能輸入字母和數字

      <input onkeyup="value=value.replace(/[^\w\.\/]/ig,'')">
      <input type="text" size="20" onkeyup="this.value=this.value.replace(/[^\w_]/g,'');">

      這個可以輸入大小寫字母和數字,下畫線

      <input type="text" size="20" onkeyup="this.value=this.value.replace(/[^\d-]/g,'')" onafterpaste="this.value=this.value.replace(/[^\d-]/g,'')">

      這個可以輸入數字,中線(電話號碼)

      <input type="text" size="20" onkeyup="this.value=this.value.replace(/[^a-z0-9_]/g,'');">

      這個可以輸入小寫字母和數字,下畫線

      <input type="text" onkeyup="value=value.replace(/[^\d.]/g,'')">

      這個可以輸入數字和點

      min、max 和 step 屬性用于包含數字、日期的 input 類型約束
      min 屬性規定輸入域所允許的最小值。
      max 屬性規定輸入域所允許的最大值。
      step 屬性為輸入域規定合法的數字間隔

      以上就是html中如何控制input輸入格式的示例的詳細內容,更多請關注php中文網其它相關文章!


      網站建設是一個廣義的術語,涵蓋了許多不同的技能和學科中所使用的生產和維護的網站。




      日韩精品一区二区三区高清