validator.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. $(document).ready(function () {
  2. $('#myModal').bootstrapValidator({
  3. message: 'This value is not valid',
  4. feedbackIcons: {
  5. valid: 'glyphicon glyphicon-ok',
  6. invalid: 'glyphicon glyphicon-remove',
  7. validating: 'glyphicon glyphicon-refresh'
  8. },
  9. fields: {
  10. username: {
  11. message: 'The username is not valid',
  12. validators: {
  13. notEmpty: {
  14. message: 'The username is required and can\'t be empty'
  15. },
  16. stringLength: {
  17. min: 6,
  18. max: 30,
  19. message: 'The username must be more than 6 and less than 30 characters long'
  20. },
  21. regexp: {
  22. regexp: /^[a-zA-Z0-9_\.]+$/,
  23. message: 'The username can only consist of alphabetical, number, dot and underscore'
  24. }
  25. }
  26. },
  27. hobby: {
  28. validators: {
  29. notEmpty: {
  30. message: 'The country is required and can\'t be empty'
  31. }
  32. }
  33. },
  34. email: {
  35. validators: {
  36. notEmpty: {
  37. message: 'The email address is required and can\'t be empty'
  38. },
  39. emailAddress: {
  40. message: 'The input is not a valid email address'
  41. }
  42. }
  43. },
  44. phoneNumber: {
  45. validators: {
  46. phone: {
  47. message: 'The input is not a valid US phone number'
  48. }
  49. }
  50. },
  51. }
  52. });
  53. $("[data-toggle='popover']").popover();
  54. })