Vue只能輸入數字正規表示式

2022-05-18 03:11:19 字數 1427 閱讀 1200

例子如下:

<

el-input

v-model.number

="jbtime"

placeholder

="請輸入數字"

oninput

="value=value.replace(/[^\d]/g,'')"

maxlength

="9"

>

<

template

slot

>.........

template

>

el-input

>

oninput="value=value.replace(/[^\d]/g,'')"

如果只能輸入數字並且不可以為0,正則如下:

oninput="value=value.replace(/^0|[^\d]/g, '')"

基於element元件輸入框只能輸入非負數可以是小數

<

el-col

:span

="24"

>

<

el-form-item

label

=" "

prop

="price"

:rules

="[

]">

<

div

class

="el-input el-input-group el-input-group--prepend"

>

<

div

class

="el-input-group__prepend"

tabindex

="-1"

>售價

div>

<

div

class

="el-input-number--medium"

style

="width:310px"

>

<

el-input-number

v-model

="modelform.price"

:controls

="false"

:min

="0"

placeholder

="請輸入售價"

>

<

template

slot

="prepend"

>售價

template

>

el-input-number

>

div>

div>

el-form-item

>

el-col

>

C TextBox只能輸入漢字(正規表示式)

前言 機房合作裡面會用到各種限制字元的,下面就介紹乙個只能輸入漢字的正規表示式。內容 機房合作中姓名,我們將它設為了只能輸入漢字,因此才有了這一篇文章。1 引用程式集 using system.text.regularexpressions 2 windows窗體上寫方法 private void ...

正規表示式限制文字框只能輸入數字

許多時候我們在製作表單時需要限制文字框輸入內容的型別,下面我們用正規表示式限制文字框只能輸入數字 小數點 英文本母 漢字等各類 1.文字框只能輸入數字 小數點也不能輸入 keyup this.value this.value.replace d g,on afterpaste this.value ...

正規表示式限制文字框只能輸入數字

摘自 許多時候我們在製作表單時需要限制文字框輸入內容的型別,下面我們用正規表示式限制文字框只能輸入數字 小數點 英文本母 漢字等各類 1.文字框只能輸入數字 小數點也不能輸入 keyup this.value this.value.replace d g,on afterpaste this.val...