Bootstraphtml5表单验证(Bootstrap)

html5表单验证(Bootstrap)

 

Bootstrap 1邮箱验证:

<input name=”email” type=”text” placeholder=”必填项”
class=”input-xlarge” required
pattern=”^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$”

title=”邮箱正确格式:xxx@xxx.xxx“>

 

密码验证:

<div class=”control-group”>

<label class=”control-label”>

密码</label>

<div class=”controls”>

<input id=”pwd” name=”pwd” type=”password” placeholder=”必填项”
class=”input-xlarge”

required onchange=”checkPasswords()”>

</div>

</div>

<div class=”control-group”>

<label class=”control-label”>

认同密码</label>

<div class=”controls”>

<input id=”pwd1″ name=”pwd1″ type=”password” placeholder=”必填项”
class=”input-xlarge”

required onchange=”checkPasswords()”>

</div>

</div>

表明格局:

<script>

function checkPasswords() {

var passl = document.getElementById(“pwd”);

var pass2 = document.getElementById(“pwd1”);

if (passl.value != pass2.value)

passl.setCustomValidity(“四回密码必须输入一致!”);

else

passl.setCustomValidity(”);

}

 

function check() {

document.getElementById(‘ok’).disabled = ‘disabled’;

}

</script>

相关文章