diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js index 85d0f22ddc85..455bf6d36e2a 100644 --- a/src/ng/directive/input.js +++ b/src/ng/directive/input.js @@ -9,7 +9,7 @@ */ var URL_REGEXP = /^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/; -var EMAIL_REGEXP = /^[a-z0-9!#$%&'*+/=?^_`{|}~.-]+@[a-z0-9-]+(\.[a-z0-9-]+)*$/i; +var EMAIL_REGEXP = /^[a-z0-9!#$%&'*+/=?^_`{|}~.-]+@[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i; var NUMBER_REGEXP = /^\s*(\-|\+)?(\d+|(\d*(\.\d*)))\s*$/; var inputType = { diff --git a/test/ng/directive/inputSpec.js b/test/ng/directive/inputSpec.js index 668fa0b54a1e..4277e26d0f21 100644 --- a/test/ng/directive/inputSpec.js +++ b/test/ng/directive/inputSpec.js @@ -946,6 +946,10 @@ describe('input', function() { expect(EMAIL_REGEXP.test('a@b.museum')).toBe(true); expect(EMAIL_REGEXP.test('a@B.c')).toBe(true); expect(EMAIL_REGEXP.test('a@.b.c')).toBe(false); + expect(EMAIL_REGEXP.test('a@-b.c')).toBe(false); + expect(EMAIL_REGEXP.test('a@b-.c')).toBe(false); + expect(EMAIL_REGEXP.test('a@3b.c')).toBe(true); + expect(EMAIL_REGEXP.test('a@b')).toBe(true); }); }); });