validate.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /**
  2. * Created by jiachenpan on 16/11/18.
  3. */
  4. /* 是否是公司邮箱*/
  5. export function isWscnEmail(str) {
  6. const reg = /^[a-z0-9](?:[-_.+]?[a-z0-9]+)*@wallstreetcn\.com$/i;
  7. return reg.test(str.trim());
  8. }
  9. /* 合法uri*/
  10. export function validateURL(textval) {
  11. const urlregex = /^(https?|ftp):\/\/([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&%$-]+)*@)*((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(:[0-9]+)*(\/($|[a-zA-Z0-9.,?'\\+&%$#=~_-]+))*$/;
  12. return urlregex.test(textval);
  13. }
  14. /* 小写字母*/
  15. export function validateLowerCase(str) {
  16. const reg = /^[a-z]+$/;
  17. return reg.test(str);
  18. }
  19. /* 验证key*/
  20. // export function validateKey(str) {
  21. // var reg = /^[a-z_\-:]+$/;
  22. // return reg.test(str);
  23. // }
  24. /* 大写字母*/
  25. export function validateUpperCase(str) {
  26. const reg = /^[A-Z]+$/;
  27. return reg.test(str);
  28. }
  29. /* 大小写字母*/
  30. export function validatAlphabets(str) {
  31. const reg = /^[A-Za-z]+$/;
  32. return reg.test(str);
  33. }