วันพุธที่ 18 กันยายน พ.ศ. 2556

php preg_match เช็ค password ตามรูปแบบที่กำหนด

ตัวอย่าง
if(!preg_match('/^(?=.*\d)(?=.*[A-Za-z])[0-9A-Za-z!@#$%]{8,12}$/', $password)) {
    echo 'the password does not meet the requirements!';
}
Between Start -> ^
And End -> $
of the string there has to be at least one number -> (?=.*\d)
and at least one letter -> (?=.*[A-Za-z])
and it has to be a number, a letter or one of the following: !@#$% -> [0-9A-Za-z!@#$%]
and there have to be 8-12 characters -> {8,12}

เพิ่มเติม คลิก

ไม่มีความคิดเห็น:

แสดงความคิดเห็น