js input 只能输入整数

JavaScript09

js input 只能输入整数,第1张

<el-input placeholder="请输入正整数" :min='1' type="number" oninput="value=value.replace(/[^\d]/g,'')" v-model="durationStart" ></el-input>

//:min='1' 最小值为1

function checkpwd(str)

{

var reg=/\d{6,}/

if(reg.test(str))

if(nojoin(str))

{

alert("yes")

return

}

alert("no")

return

}

function nojoin(str)

{

for(i=0i<str.length-2i++)

{

if((parseInt(str[i])==parseInt(str[i+1])+1) || (parseInt(str[i])==parseInt(str[i+1])-1))

{

return false

break

}

}

return true

}

checkpwd("0123456")//no

checkpwd("1746")//no

checkpwd("0827AG6")//no

checkpwd("4618394")//yes

保存到记事本中是啥意思?