久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<tfoot id='ZBDSn'></tfoot>
      <bdo id='ZBDSn'></bdo><ul id='ZBDSn'></ul>
    1. <legend id='ZBDSn'><style id='ZBDSn'><dir id='ZBDSn'><q id='ZBDSn'></q></dir></style></legend>

      <small id='ZBDSn'></small><noframes id='ZBDSn'>

    2. <i id='ZBDSn'><tr id='ZBDSn'><dt id='ZBDSn'><q id='ZBDSn'><span id='ZBDSn'><b id='ZBDSn'><form id='ZBDSn'><ins id='ZBDSn'></ins><ul id='ZBDSn'></ul><sub id='ZBDSn'></sub></form><legend id='ZBDSn'></legend><bdo id='ZBDSn'><pre id='ZBDSn'><center id='ZBDSn'></center></pre></bdo></b><th id='ZBDSn'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='ZBDSn'><tfoot id='ZBDSn'></tfoot><dl id='ZBDSn'><fieldset id='ZBDSn'></fieldset></dl></div>
      1. 如何使 HTML 輸入標(biāo)簽只接受數(shù)值?

        How to make HTML input tag only accept numerical values?(如何使 HTML 輸入標(biāo)簽只接受數(shù)值?)

        <tfoot id='ANmWI'></tfoot>
          <tbody id='ANmWI'></tbody>

              <bdo id='ANmWI'></bdo><ul id='ANmWI'></ul>
            • <i id='ANmWI'><tr id='ANmWI'><dt id='ANmWI'><q id='ANmWI'><span id='ANmWI'><b id='ANmWI'><form id='ANmWI'><ins id='ANmWI'></ins><ul id='ANmWI'></ul><sub id='ANmWI'></sub></form><legend id='ANmWI'></legend><bdo id='ANmWI'><pre id='ANmWI'><center id='ANmWI'></center></pre></bdo></b><th id='ANmWI'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='ANmWI'><tfoot id='ANmWI'></tfoot><dl id='ANmWI'><fieldset id='ANmWI'></fieldset></dl></div>

              <small id='ANmWI'></small><noframes id='ANmWI'>

                <legend id='ANmWI'><style id='ANmWI'><dir id='ANmWI'><q id='ANmWI'></q></dir></style></legend>

                • 本文介紹了如何使 HTML 輸入標(biāo)簽只接受數(shù)值?的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我需要確保某個(gè) <input> 字段僅將數(shù)字作為值.輸入不是表單的一部分.因此它不會被提交,因此在提交期間進(jìn)行驗(yàn)證不是一種選擇.我希望用戶不能輸入除數(shù)字以外的任何字符.

                  有沒有一種巧妙的方法來實(shí)現(xiàn)這一點(diǎn)?

                  解決方案

                  HTML 5

                  您可以使用 HTML5 輸入類型編號 僅限制數(shù)字條目:

                  這僅適用于 HTML5 投訴瀏覽器.確保您的 html 文檔的 doctype 是:

                  <!DOCTYPE html>

                  另請參閱 https://github.com/jonstipe/number-polyfill 以獲得透明支持在舊版瀏覽器中.

                  JavaScript

                  更新:有一個(gè)新的非常簡單的解決方案:

                  <塊引用>

                  它允許您在文本 <input> 上使用 任何 類型的輸入過濾器,包括各種數(shù)字過濾器.這將正確處理復(fù)制+粘貼、拖放、鍵盤快捷鍵、上下文菜單操作、不可鍵入的鍵和所有鍵盤布局.

                  請參閱此答案或自己嘗試在 JSFiddle 上.

                  出于一般目的,您可以進(jìn)行 JS 驗(yàn)證,如下所示:

                  function isNumberKey(evt){var charCode = (evt.which) ?evt.which : evt.keyCodeif (charCode > 31 && (charCode < 48 || charCode > 57))返回假;返回真;}<input name="someid" type="number" onkeypress="return isNumberKey(event)"/>

                  如果您想允許小數(shù),請將if 條件"替換為:

                  if (charCode > 31 && (charCode != 46 &&(charCode < 48 || charCode > 57)))

                  來源:HTML文本輸入只允許數(shù)字輸入p>

                  JSFiddle 演示:http://jsfiddle.net/viralpatel/nSjy7/

                  I need to make sure that a certain <input> field only takes numbers as value. The input is not part of a form. Hence it doesn't get submitted, so validating during submission is not an option. I want the user to be unable to type in any characters other than numbers.

                  Is there a neat way to achieve this?

                  解決方案

                  HTML 5

                  You can use HTML5 input type number to restrict only number entries:

                  <input type="number" name="someid" />
                  

                  This will work only in HTML5 complaint browser. Make sure your html document's doctype is:

                  <!DOCTYPE html>

                  See also https://github.com/jonstipe/number-polyfill for transparent support in older browsers.

                  JavaScript

                  Update: There is a new and very simple solution for this:

                  It allows you to use any kind of input filter on a text <input>, including various numeric filters. This will correctly handle Copy+Paste, Drag+Drop, keyboard shortcuts, context menu operations, non-typeable keys, and all keyboard layouts.

                  See this answer or try it yourself on JSFiddle.

                  For general purpose, you can have JS validation as below:

                  function isNumberKey(evt){
                      var charCode = (evt.which) ? evt.which : evt.keyCode
                      if (charCode > 31 && (charCode < 48 || charCode > 57))
                          return false;
                      return true;
                  }
                  
                  <input name="someid" type="number" onkeypress="return isNumberKey(event)"/>
                  

                  If you want to allow decimals replace the "if condition" with this:

                  if (charCode > 31 && (charCode != 46 &&(charCode < 48 || charCode > 57)))
                  

                  Source: HTML text input allow only numeric input

                  JSFiddle demo: http://jsfiddle.net/viralpatel/nSjy7/

                  這篇關(guān)于如何使 HTML 輸入標(biāo)簽只接受數(shù)值?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  JavaScript innerHTML is not working for IE?(JavaScript innerHTML 不適用于 IE?)
                  document.write() overwriting the document?(document.write() 覆蓋文檔?)
                  AngularJS Error: Cross origin requests are only supported for protocol schemes: http, data, chrome-extension, https(AngularJS 錯(cuò)誤:跨源請求僅支持協(xié)議方案:http、data、chrome-extension、https) - IT屋-程序員軟件開發(fā)技術(shù)分
                  IE10 and Cross-origin resource sharing (CORS) issues with Image / Canvas(IE10 和 Image/Canvas 的跨域資源共享 (CORS) 問題)
                  Importing script with type=module from local folder causes a CORS issue(從本地文件夾導(dǎo)入 type=module 的腳本會導(dǎo)致 CORS 問題)
                    <bdo id='AjWQK'></bdo><ul id='AjWQK'></ul>
                        <tbody id='AjWQK'></tbody>
                    1. <tfoot id='AjWQK'></tfoot>

                        <i id='AjWQK'><tr id='AjWQK'><dt id='AjWQK'><q id='AjWQK'><span id='AjWQK'><b id='AjWQK'><form id='AjWQK'><ins id='AjWQK'></ins><ul id='AjWQK'></ul><sub id='AjWQK'></sub></form><legend id='AjWQK'></legend><bdo id='AjWQK'><pre id='AjWQK'><center id='AjWQK'></center></pre></bdo></b><th id='AjWQK'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='AjWQK'><tfoot id='AjWQK'></tfoot><dl id='AjWQK'><fieldset id='AjWQK'></fieldset></dl></div>

                        1. <legend id='AjWQK'><style id='AjWQK'><dir id='AjWQK'><q id='AjWQK'></q></dir></style></legend>

                          <small id='AjWQK'></small><noframes id='AjWQK'>

                          • 主站蜘蛛池模板: 久久高清国产视频 | 三级av在线 | 亚洲视频精品在线 | 国产成人免费 | 夜夜艹| 国产一区二区影院 | 日韩视频一区二区三区 | 亚洲 欧美 日韩在线 | 日韩国产免费观看 | 亚洲欧美日韩国产综合 | 91tv在线观看 | xx性欧美肥妇精品久久久久久 | 亚洲午夜精品视频 | 欧美精品一二三 | 成人免费大片黄在线播放 | 久久精品一区二区 | 欧洲视频一区 | 日韩国产欧美在线观看 | 亚洲高清在线视频 | 精品日韩一区二区三区av动图 | 亚洲 成人 av | 罗宾被扒开腿做同人网站 | 欧美极品视频 | 欧美亚洲另类丝袜综合网动图 | 欧美日韩在线国产 | 久久久久久国产精品免费免费狐狸 | 日韩在线免费视频 | 影音先锋中文字幕在线观看 | 亚洲精品一区二区三区中文字幕 | 日韩免费福利视频 | 99国内精品久久久久久久 | 91精品久久久久久久久久 | 在线成人av| 久久久91精品国产一区二区三区 | 国产一区在线看 | 国产精品不卡 | av一级毛片 | www.狠狠操| 精品一区二区久久久久久久网站 | 8x国产精品视频一区二区 | 亚洲高清在线 |