extract( $_POST );
// determine whether phone number is valid and print
// an error message if not
if ( !@ereg( "^[0-9]{3}-[0-9]{7}$", $phone))
{
echo( "<SCRIPT LANGUAGE='JavaScript'>
window.alert('Please insert a valid phone number with (xxx-xxxxxxx) format.')
window.location.href='';
</SCRIPT>");
}
else if (!@preg_match('/^(?=.*\d{3,})(?=.*[A-Za-z]{5,})[0-9A-Za-z!@#$%]{8,32}$/', $pass))
{
echo("<SCRIPT LANGUAGE='JavaScript'>
window.alert('Password must be at least 8 characters long and must contain at least 1 number and 1 letter')
window.location.href='';
</SCRIPT>");
}
我不确定上面的编码有什么问题,但我似乎无法获得正确的密码值?它会一直显示相同的错误消息
答案 0 :(得分:0)
如果您使用这些条件完全 8个字符,那么您需要这样的内容:
var item = {
"_id": {
"$oid": "asdf976"
},
"Categories": [{
"mainmodels": [{
"submodels": [{
"price": "2000",
"submodelname": "lumia021",
"Remainingphones": "0",
"Bookedphones": "0",
"Numofphones": "10"
}, {
"price": "2000",
"submodelname": "lumia341",
"Remainingphones": "5",
"Bookedphones": "5",
"Numofphones": "10"
}
],
"Status": "Active",
"modelname": "lumia",
"fromdate": "2016-04-01T16:39:12.051Z",
"todate": "2016-04-31T19:19:44.051Z"
}],
"brand": "nokia"
}],
"rank": "1",
"name": "first"
};
var modal = {
custid: '1',
packcode: '22'
};
Object.assign(item, modal);
// Note: Just using JSON for *display*
document.body.innerHTML =
"<pre>" + JSON.stringify(item, null, 2) + "</pre>";
答案 1 :(得分:0)
你的正则表达式意味着什么?
^(?=.*\d{3,})(?=.*[A-Za-z]{5,})[0-9A-Za-z!@#$%]{8,32}$
正则表达式细分
^ #Start of string
(?=.*\d{3,}) #Match at least 3 consecutive digits anywhere in string
(?=.*[A-Za-z]{5,}) #Match at least 5 consecutive characters from the set anywhere in string
[0-9A-Za-z!@#$%]{8,32} #Ensure that length of string is in between 8 and 32
$ #End of string
这将给出你想要的东西(按你在问题中描述的那样)
(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])
正则表达式细分
(?=.{8,}) #Ensure that string is of at least length 8
(?=.*[A-Z]) #Match a single capital letter anywhere in string
(?=.*[a-z]) #Match a single small letter anywhere in string
(?=.*\d) #Match a single digit anywhere in string