Commit c8cf91523b1d2e648f3e423f583e395819dd45d0

Authored by Luciano Prestes
1 parent 180ad529

Fix bug in email validation regex

Signed-off-by: Charles Oliveira <18oliveira.charles@gmail>
Signed-off-by: Lucas Moura <lucas.moura128@gmail.com>
Signed-off-by: Luciano Prestes Cavalcanti <lucianopcbr@gmail.com>
app/views/account/_signup_form.html.erb
@@ -135,6 +135,10 @@ @@ -135,6 +135,10 @@
135 135
136 <script type="text/javascript"> 136 <script type="text/javascript">
137 jQuery(function($) { 137 jQuery(function($) {
  138 + $.validator.addMethod('validEmail', function(value, element) {
  139 + var regex = /^([^\W_])([\w.-]+)@((?:[-_a-z0-9]+\.)+[a-z]{2,})$/i;
  140 + return this.optional(element) || regex.test(value);
  141 + }, 'Please enter a valid e-mail');
138 142
139 $('#signup-form input[type=text], #signup-form textarea').each(function() { 143 $('#signup-form input[type=text], #signup-form textarea').each(function() {
140 $(this).bind('blur', function() { 144 $(this).bind('blur', function() {
lib/noosfero/constants.rb
1 module Noosfero::Constants 1 module Noosfero::Constants
2 - EMAIL_FORMAT = /\A([^@\s]+)@((?:[-_a-z0-9]+\.)+[a-z]{2,})\Z/i 2 + EMAIL_FORMAT = /\A([^\W_])([\w.-]+)@((?:[-_a-z0-9]+\.)+[a-z]{2,})\Z/
3 INTEGER_FORMAT = /\A\d*\Z/i 3 INTEGER_FORMAT = /\A\d*\Z/i
4 PROFILE_PER_PAGE = 10 4 PROFILE_PER_PAGE = 10
5 -end 5 -end
  6 +end
6 \ No newline at end of file 7 \ No newline at end of file