[英]Semantic UI Form Match Validation Not Working
// Register form validation
$('.register-form')
.form({
on: 'blur',
fields: {
registerEmail: {
identifier : 'registerEmail',
rules: [{
type : 'email',
prompt : 'Please enter a valid email address.'
}]
},
registerPassword: {
identifier : 'registerPassword',
rules: [{
type : 'empty',
prompt : 'Please enter a password.'
}]
},
registerPasswordVerify: {
identifier : 'registerPasswordVerify',
rules: [{
type : 'match[registerPassword]',
prompt : 'Your passwords do not match.'
}]
}
},
onSuccess: function() {
$scope.createUser();
console.log("Passed");
},
onFailure: function() {
console.log("Failed");
}
});
Not sure what is wrong here exactly, but I'm simply trying to get the two password fields to match but I keep getting the "Your passwords do not match" error. 不确定这里到底有什么问题,但我只是想让两个密码字段匹配,但我一直得到“你的密码不匹配”的错误。 Here's my HTML as well:
这是我的HTML:
<div class="field">
<label>Password</label>
<input type="password" name="registerPassword" ng-model="password">
</div>
<div class="field">
<label>Verify Password</label>
<input type="password" name="registerPasswordVerify">
</div>
I had the same problem. 我有同样的问题。 After trying few options, i realize that
registerPassword
inside match[registerPassword]
is undefined. 尝试几个选项后,我意识到,
registerPassword
内match[registerPassword]
是不确定的。 match
is not looking for name of the input, but the id
of the input. match
不是要查找输入的名称,而是输入的id
。
So if you put id="registerPassword"
in your password input. 因此,如果您在密码输入中输入
id="registerPassword"
。 That should work. 这应该工作。 I don't know why this is not in the documentation.
我不知道为什么这不在文档中。
you will working just add id name of every input 你只需要添加每个输入的id名称
<div class="field"> <label>Verify Password</label> <input type="password" name="registerPasswordVerify" id="registerPassword"> </div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.