簡單的表單驗證

2022-05-27 20:18:11 字數 2507 閱讀 1095

效果圖:

失焦驗證,點選按鈕再次驗證,驗證通過切換

使用者註冊

<

input

type

="text"

name

=""id

="name"

v-model

="data.name"

placeholder

="使用者名稱"

@blur

="aa"

/>

<

span

class

="name_msg"

>}

span

>

<

input

type

="text"

name

=""id

="num"

v-model

="data.num"

placeholder

="驗證碼"

@blur

="bb"

/>

<

span

class

="num_msg"

>}

span

>

<

div

class

="btn"

@click

="next"

>下一步

div>

div>

<

div

class

="content2"

v-if

="xyb == 1"

>

設定密碼

<

input

type

="password"

name

=""id

="pwd1"

placeholder

="請輸入密碼"

v-model

="data.psw1"

@blur

="cc"

/>

<

span

class

="psw1_msg"

>}

span

>

<

input

type

="password"

name

=""id

="pwd2"

v-model

="data.psw2"

placeholder

="再次輸入密碼"

@blur

="dd"

/>

<

span

class

="psw2_msg"

>}

span

>

<

div

class

="btn"

>提交

div>

div>

div>

export default

, check: ,

};},

methods:

elseif(

!/^[a-za-z0-9_-]$/.test(this

.data.name)

) else

},bb()

else

if (!/^[0-9]$/.test(this

.data.num))

else

},next()

else

if (!this.aa() == true

) else

if (!this.bb() == true

) else

},cc()

else

if (!/^[0-9]$/.test(this

.data.psw1))

else

},dd()

else

if (!(this.data.psw1 === this

.data.psw2))

else

},},

};

.name_msg,

.psw1_msg,

.psw2_msg,

.num_msg

.btn

.content1,

.content2

.test

input

簡單表單驗證的公共函式

首先要新增require req valid type 需要驗證的 class forminfo 姓名 b label name staff name class dfinput value type text require req valid type normal label li 工號 b ...

python表單驗證 表單驗證

django有乙個form類為我們提供了強大的表單驗證提交。1 建立form from django import forms class commentform forms.form name forms.charfield label 您的姓名 max length 100 email form...

JS JQ簡單的表單失焦驗證

js jq簡單的表單失焦驗證 鄧強 以下 僅供參考。驗證使用者名稱 function ckname if username else if rename.test username else function ckname1 密碼失去焦點驗證 function ckpassword if passw...