<script type="text/javascript">
document.addEventListener('DOMContentLoaded', function() {
    document.getElementById("address_back_button").addEventListener('click', function(){
      location.href = '<%= address_books_path %>';
    });
    document.getElementById("address_submit_button").addEventListener('click', function(){
      document.querySelector("form").submit();
    });
})

localDomains = "<%= @local_domains %>";
$(document).ready(function() {
  $.validationEngineLanguage.newLang(localDomains);
  $("form").validationEngine({promptPosition: "centerRight", binded: false})
});
</script>

<%= form_with(model: @address_book) do |f| %>
  <% if @address_book.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@address_book.errors.count, "error") %> prohibited this address_book from being saved:</h2>

      <ul>
      <% @address_book.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
      </ul>
    </div>
  <% end %>

  <div class="comment">
  <div class="table-address-a">
    <div class="item-top">
      <%= f.label :organization %>
    </div>
    <div class="input-top">
      <%= f.text_field :organization, class: 'validate[maxSize[20]]', size: 40 %>
    </div>
    <div class="item-mid">
      <%= f.label :name %><span class="required">※</span>
    </div>
    <div class="input-mid">
      <%= f.text_field :name, class: 'validate[required, maxSize[50]]', size: 40 %>
    </div>
    <div class="item-mid">
      <%= f.label :email %><span class="required">※</span>
    </div>
    <div class="input-mid">
      <%= f.text_field :email, class: 'validate[required, maxSize[255], custom[email]]', size: 40 %>
    </div>
    <div class="item-bot">
      <%= f.label :notes %>
    </div>
    <div class="input-bot">
      <%= f.text_field :notes, class: 'validate[maxSize[100]]', size: 40 %>
    </div>
  </div>

<% end %>

&nbsp;</br>

<div id="address_submit"><input type="button" value="戻る" id="address_back_button" style="margin-left:0px;"/>&nbsp;&nbsp;<input type="button" value="登録" id="address_submit_button" style="margin-left:0px;"/></div>

</div>
