Numinput 自定義數字輸入框

2021-07-05 00:05:33 字數 777 閱讀 6403

1.1 data-num:|int|int-|float|float-|

data-num="int" 正整數

data-num="int-" 整數 包含負整數

data-num="float" 正數

data-num="float-" 包含負數的一起數字

1.2 max-length 正數部分有多少位 預設為99999

max-length="5"

1.3 decimal-length 小數部分有多少位只針對data-num為浮點型的有效 預設最多保留2位

2.1 直接引用js

2.2 給傳統的input新增data-num=「xx」即可

2.3 詳見事例

3.1 谷歌存在imemode相容性,即在谷歌瀏覽器如果使用者開啟輸入法為中文,還是可以輸入非數字

.focus(function())

3.2 火狐瀏覽器下createrange的相容性,如果輸入的文字已經超過最大限制,選中部分數字,輸入新的數字,不能替換

//獲取選中的文字

varfungetselecttxt = function() else

// returntxt.tostring();

var txt = "";

if (window.getselection) else if (window.document.getselection) else if (window.document.selection)

return txt;

}4 說明

git:

全域性自定義指令,限制只能輸入數字

1 在utils中新建乙個testinput.js檔案,testinput中的 如下 註冊全域性自定義指令 保留整數 function inputpdint e,data,name false else 保留兩位小數 function inputpdtwo e,data,name false g r...

C 自定義輸入函式

題目 自定義兩個輸入函式,第乙個列印字串,不新增 n 第二個列印字串,並統計列印的字元數 第二個函式增加乙個計數變數。程式如下 include void put1 const char string int put2 const char string int main void put1 cons...

winform 擴充套件控制項 自定義只輸入數字及點號。

自定義textbox控制項,實現智慧型輸入數字和點號 如下 public class textboxextention textbox protected override void wndproc refmessage m 處理 windows 訊息。if char.equals char m.w...