jquery密码规则
之前尝试过发布此内容,但它没有通过(我认为),所以如果这是重新发布,请忽略。然而,我昨天问了一个问题,并在这里的大力帮助下解决了这个问题。我有一个用户帐户页面,用户可以在其中编辑他们的帐户信息。现在,他们并不总是更改密码。因此,我仅在新密码框有输入时才需要当前密码框。我还应用了 equalTo: 以便我可以使用新密码框检查确认密码框。这就是全部工作。但是,现在我想对新密码框应用一些规则。例如密码必须至少有 6 个字符长,包含 1 个字母和 1 个数字,并且不能包含其他字符。有人可以指出我正确的方向吗?
这是我的最小长度的一些代码:
$(<%= NewPass1.GetName() %>").rules("add", {
minlength: 6,
SOME REGEX HERE?
Tried posting this before but it did not go through (i think) so if this is a repost please disregard. However, I asked a question yesterday and figured it out with the wonderful help from here. I have a user account page where a user can edit their account information. Now, they don't always change their password. So, I made the Current Password box required only when the new password box had an input. I also applied equalTo: so that I can check the confirm password box with the new password box. That is all working. However, now I want to apply some rules to the new password box. Like the password has to be at least 6 chars long, contain one letter and one number, and not contain other characters. Can somebody please point me in the right direction?
here is some of the code I have for the min length:
$(<%= NewPass1.GetName() %>").rules("add", {
minlength: 6,
SOME REGEX HERE?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个功能。它检查密码是否为字母数字且长度至少为 6 个字符。它还检查它是否至少包含一位数字和一个字母。
我假设您正在使用验证插件。要在插件中使用自定义方法,请尝试以下功能: http://docs .jquery.com/Plugins/Validation/Validator/addMethod#namemethodmessage
编辑:
编辑为允许除空格和“%”之外的所有字符。
Try this function. It checks that the password is alphanumeric and at least 6 characters long. It also checks that it contains at least one digit and one letter.
I assume you are using the Validation plugin. To use a custom method with the plugin, try this function: http://docs.jquery.com/Plugins/Validation/Validator/addMethod#namemethodmessage
EDIT:
Edited to allow all characters except spaces and '%'.