<commit_before><h2>Sign in</h2>

<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
  <%= devise_error_messages! %>
  <div><%= f.label :email %><font color=red> *</font><br />
  
  <%= f.email_field :email,  :id => "email_field" ,autofocus: true %>
     <span id='email_error' style="display:none;"><font color="red" size="1"> <br>Please enter email</br></font></span>
  </div>

  <div><%= f.label :password %><font color=red> *</font><br />
    <%= f.password_field :password, :id => "password_field",autocomplete: "off" %>
   <span id='password_error' style="display:none;"><font color="red" size="1"> <br>Please enter password</br></font></span>  
  </div>

  <% if devise_mapping.rememberable? -%>
    <div><%= f.check_box :remember_me %> <%= f.label :remember_me %></div>
  <% end -%>

  <div>  <%= f.submit "Sign in", :onclick=> "return validate_service();" %></div>
<% end %>

<script>
function validate_service()
{
if (($("#email_field").val() == '' || $("#email_field").val() == null) && 
($("#password_field").val() == '' || $("#password_field").val() == null))
	{
		$("#email_error").show();
		$("#password_error").show();
		return false;
	}
	else if ($("#email_field").val() == '' || $("#email_field").val() == null)
	{
		$("#email_error").show();
		$("#password_error").hide();
		
		return false;
	}
	else if ($("#password_field").val() == '' || $("#password_field").val() == null)
	{
		$("#email_error").hide();
		$("#password_error").show();
		return false;
	}
	return true;
}
</script>
<commit_msg>Email validation in sign in view<commit_after><h2>Sign in</h2>

<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
  <%= devise_error_messages! %>
  <div><%= f.label :email %><font color=red> *</font><br />
  
  <%= f.email_field :email,  :id => "email_field" ,autofocus: true %>
     <span id='email_error' style="display:none;"><font color="red" size="1"> <br>Please enter email</br></font></span>
     <span id='valid_email_error' style="display:none;"><font color="red" size="1"> <br>Please enter valid email</br></font></span>
  </div>

  <div><%= f.label :password %><font color=red> *</font><br />
    <%= f.password_field :password, :id => "password_field",autocomplete: "off" %>
   <span id='password_error' style="display:none;"><font color="red" size="1"> <br>Please enter password</br></font></span>  
  </div>

  <% if devise_mapping.rememberable? -%>
    <div><%= f.check_box :remember_me %> <%= f.label :remember_me %></div>
  <% end -%>

  <div>  <%= f.submit "Sign in", :onclick=> "return validate_service();" %></div>
<% end %>

<script>
function validate_service()
{

  var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  if(regex.test($("#email_field").val())==false)
  {
		$("#valid_email_error").show();
		$("#email_error").hide();
		$("#password_error").show();
		return false;
  }
  
  else 
  {

	if (($("#email_field").val() == '' || $("#email_field").val() == null) && 
	($("#password_field").val() == '' || $("#password_field").val() == null))
	{
		$("#email_error").show();
		$("#valid_email_error").hide();
		$("#password_error").show();
		return false;
	}
	else if ($("#email_field").val() == '' || $("#email_field").val() == null)
	{
		$("#email_error").show();
		$("#valid_email_error").hide();
		$("#password_error").hide();
		
		return false;
	}
	else if ($("#password_field").val() == '' || $("#password_field").val() == null)
	{
		$("#email_error").hide();
		$("#valid_email_error").hide();
		$("#password_error").show();
		return false;
	}
   }	
	return true;
}
</script>
{'fraction_non_alphanumeric': 0.2718232044198895, 'fraction_numerical': 0.004696132596685083, 'mean_word_length': 4.684458398744113, 'pattern_counts': {'":': 0, '<': 93, '<?xml version=': 0, '>': 99, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3296840', 'n_tokens_mistral': 1391, 'n_tokens_neox': 1308, 'n_words': 235}