I'm using Rails -3.2.1. In one of my form I'm using jquery validation.
My form is below

----------------------------------------------------------------------
new_account.html.erb

<%= form_for(@account, :url =>{:action=> "create_account"}) do |f| %>

<table width="80%" border="1" align="center" cellpadding="5"
cellspacing="5">
  <tr>
      <td width="30%">
      <%= f.label :Account_Name, :class => :style1_bold %>
      </td>
      <td>
      <%= f.text_field :account_name, :class =>"input_border required
ONLY_ALPHABET" %>
      </td>
      </tr>
    <tr>
        <td>
            &nbsp;
        </td>
        <td>
       <%=f.submit "Add Account" %>
       <%= link_to "Cancel", home_path, :class=>"style2_link" %>
            </td>
            </tr>
        </table>
        <% end %>
----------------------------------------------------------------------
In application.js

    //= require jquery
    //= require jquery_ujs
    // require_tree .
    //= require_directory .

        jQuery.noConflict();
        jQuery(document).ready(function(){



          /////////////////////////////////////////////
            //// Validatior for only alphabet
            /////////////////////////////////////////////
            jQuery.validator.addMethod("ONLY_ALPHABET",function(value,element){
                return this.optional(element) || /^[a-zA-Z
]+$/.test(value);
            },"Only Alphabet is allowed");

          /////////////////////////////////////////////
            //// Validation for Create Account
            /////////////////////////////////////////////
            jQuery("#new_account").validate(
            {
                  rules: {
                    account_account_name: {
                        required: true,
                ONLY_ALPHABET: true,
                        maxlength: 30
                    }
                },
                messages: {
                    account_account_name: {
                        required: "Please fill category",
                        ONLY_ALPHABET: "Only Alphabet is allowed",
                        maxlength: "Not more than 30 characters"
                    }
                }
            });

        });
----------------------------------------------------------------------
On Form submit. It doesn't show my message instead it show jquery
default messages.

I include this file jquery.validate.min.js

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to