rails jquery ajax form validation -


I'm looking for some Ajax form validation with jquery. Everything is in place and I can return my errors to the Jason object which looks like something:

  errors => {"First_name": "can not be blank", "password": "can not be empty", "lastname": "can not be empty", "email": "can not be empty"}  < / Pre> 

This works fine if I want to display error messages at the top. Although I would like to do something similar to some railway validation where it is surrounded with 'fieldwise arrows' and surrounded with error field (in fact I just want to add the field 'Field with Esther' in the error zone)

< P> I'm not sure where the train magic gets the correct error field and the error div is called, I'm looking for the code so that I can return a Jason object which is the error message Words and actual ID of the error field so I can update it with the appropriate class. Of course I can only include the object name (user in this case) of the field returned in Jason object (i.e. 'first_name'), although I want it to be a generic function that is for any form May work.

Can someone point me at the place where the actual ID of the error field is generated. I should be able to do something like @ objects. Errors [: first_name] .field_id So I can return the same JSian object above, except for my key 'first_name', actually 'user_first_name', error field of id.

In actionpack / lib / action_view / helpers / form_helper.rb to see how the train gets done See.

Here are the methods in form_helper.rb which define the tag ID

  def tag_id "# {sanitized_object_name} _ # {sanitized_method_name} _" {@} sanitized_object_name @ Sanitized_object_name | | = @ Object_name.gsub (/ \] \ [| - [^ - a-zA-Z0-9:] /, "_"). Sub (/ _ $ /, "") end def sanitized_method_name @sanitized_method_name || = @ Method_name.sub (/ \? $ /, "") End  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -