jQuery Twitter 引导程序比较密码验证

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19828904/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 00:40:59  来源:igfitidea点击:

Twitter bootstrap compare password validation

jquerycssvalidationtwitter-bootstrap

提问by NewtonCode

I have done a basic form using twitter bootstrap . I was able to perform some validation also.

我已经使用 twitter bootstrap 完成了一个基本表单。我也能够执行一些验证。

<form class="form-signin">            
<input type="email" class="input-block-level" placeholder="Email address" required="">
<input type="password" class="input-block-level" placeholder="Password" required="">
<input type="password" class="input-block-level" placeholder="ConfirmPassword" required="">
<button class="btn btn-large btn-primary" type="submit">Sign in</button>
</form>

In numerous examples i searched , nobody has used compare password validation. I was wondering if there is a compare password validation in twitter bootstrap other than using j query validator ? Can compare password validation be performed by using css and not by using form.validate() script?

在我搜索的众多示例中,没有人使用过比较密码验证。我想知道除了使用 j 查询验证器之外,twitter bootstrap 中是否还有比较密码验证?可以使用 css 而不是使用 form.validate() 脚本来比较密码验证吗?

Thanks

谢谢

回答by Rohan Kumar

You can't validate a formusing css, if you don't want jquery validate pluginthen you can try it like,

你不能validate a form使用css,如果你不想要,jquery validate plugin那么你可以像这样尝试,

$('form').on('submit',function(){
   if($('#pass').val()!=$('#cpass').val()){
       alert('Password not matches');
       return false;
   }
   return true;
});

HTML

HTML

<form class="form-signin">
    <input type="email" class="input-block-level" placeholder="Email address" required="">
    <input id="pass" type="password" class="input-block-level" placeholder="Password" required="">
    <input id="cpass" type="password" class="input-block-level" placeholder="ConfirmPassword" required="">
    <button class="btn btn-large btn-primary" type="submit">Sign in</button>
</form>

回答by Praveen

HTML:

HTML:

<input type="password" class="input-block-level" placeholder="Password" required="" id="psd">
<input type="password" class="input-block-level" placeholder="ConfirmPassword" required="" id="confirmPsd">

I've added idfor more convenient.

id为了方便,我加了。

JS:

JS:

$('button').on ('click', function () {
if ($('#confirmPsd').val() === $('#psd').val()) {
  alert("Equal");
  return true;
}
else {
  alert("don't matches");
 return false;
}
})