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| %>
<%= f.label :Account_Name, :class => :style1_bold %> | <%= f.text_field :account_name, :class =>"input_border required ONLY_ALPHABET" %> |
<%=f.submit "Add Account" %> <%= link_to "Cancel", home_path, :class=>"style2_link" %> |
//= 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