emailAddress.js 994 B

123456789101112131415161718192021
  1. (function($) {
  2. $.extend($.bootstrapValidator.validator, {
  3. emailAddress: {
  4. /**
  5. * Return true if and only if the input value is a valid email address
  6. *
  7. * @param {bootstrapValidator} validateInstance Validate plugin instance
  8. * @param {HTMLElement} element
  9. * @param {Object} options
  10. * @returns {boolean}
  11. */
  12. validate: function(validateInstance, element, options) {
  13. var value = $.trim($(element).val()),
  14. // Email address regular expression
  15. // http://stackoverflow.com/questions/46155/validate-email-address-in-javascript
  16. emailRegExp = /^(([^<>()[\]\\.,;:\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,}))$/;
  17. return emailRegExp.test(value);
  18. }
  19. }
  20. });
  21. }(window.jQuery));