js密码过于简单检验

function test(s) {
if (!/^d{6}$/.test(s)) return false; // 不是6位数字
if (/^(d)1+$/.test(s)) return false; // 全一样

var str = s.replace(/d/g, function($0, pos) {
return parseInt($0)-pos;
});
if (/^(d)1+$/.test(str)) return false; // 顺增

str = s.replace(/d/g, function($0, pos) {
return parseInt($0)+pos;
});
if (/^(d)1+$/.test(str)) return false; // 顺减
return true;

原文地址:https://www.cnblogs.com/zhouzhou163/p/7573229.html