Created
June 25, 2017 10:37
-
-
Save benny-sun/97d6aa513058790addb3385fcb6d71ce to your computer and use it in GitHub Desktop.
input validation regex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var regex = { | |
Name: /^([\u4e00-\u9fa5A-z\s]{0,})$/, | |
Mobile: /^(09\d{2})?((\+)?886\d{3})?-?\d{3}-?\d{3}$/, | |
Tel: /^(0\d+)-?(-?[\d{7,8}])+(?:(?:#)(\d+))?$/, | |
Address: /^[^;'<>@#\$%\^&\*]+$/, | |
Email: /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/, | |
Integer: /^[+\-]?\d+$/, | |
PositiveInt: /^\d+$/, | |
Numeric: /[0-9]+.[0-9]+/, | |
Url: /(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/, | |
Youtube: /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=|\?v=)([^#\&\?]*).*/, | |
Account: /^[A-z0-9]+$/, | |
Password_01: /.*/, //任意字 | |
Password_02: /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{0,}$/, //至少 1字母 1數字 | |
Password_03: /"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{0,}$"/ //至少 1大寫字母 1小寫字母 1數字 | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment