GithubHelp home page GithubHelp logo

jej / clever_validation Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ericalli/clever_validation

3.0 3.0 0.0 84 KB

CleverValidation is an extension to rails validation methods that includes the ability to customize your validation error messages and features some javascript functionality for adding a bit of interaction to your validations via scriptaculous effects.

Home Page: http://plugins.two2twelve.com

License: MIT License

clever_validation's Introduction

CleverValidation v0.1
=====================

CleverValidation is an extension to the existing rails validation methods that includes the ability to customize your validation error messages and features javascript functionality for adding a bit of interaction to your validations via scriptaculous effects.


Example
=======

Use this plugin in the exact manner you would use the default error_messages_for method. A basic example would be:

<%= clever_validation_for 'your_model_name', :title => "Sorry, we encountered some errors during your submission.", 
										      :sub_title => "The errors in question are listed below...", 
										      :effect => "pulsate" %>
										
This will display the error messages and a "show me" link next to each error, when clicked, it will scroll a user to the field in question and do the defined effect to it (in this case Effect.pulsate).

The available effects are:

- Pulsate
- Shake
- Highlight
	- highlight_color
	- duration
	
An example with the highlight effect would be:

<%= clever_validation_for 'your_model_name', :title => "Sorry, we encountered some errors during your submission.", 
										      :sub_title => "The errors in question are listed below...", 
										      :effect => "highlight",
										 	  :highlight_color => "eaeaea", 
											  :duration => 8 %>

NOTE: I've overwritten the default rails validation messages for the model validation methods, so you will need to completely define your messages (which, I think would be preferred). Such as:

validates_presence_of :file_name, :message => "This field can't be blank."

This way the error will appear exactly as: "This field can't be blank."


Basic CSS Styles:
=================

Here are some basic styles to get you started. Place these into your CSS stylesheet and tweak them as you wish.

div#cleverValidation {
    background: #FFFF99;
	padding: 10px;
	position: relative;
}
div#cleverValidation ul{
	list-style:none;
}
div#cleverValidation a#hideLink {
	position: absolute;
	top: 10px;
	right: 10px;
}
div#cleverValidation a#showMeLink {}


Credits
=======

Copyright (c) 2008 Eric A. released under the MIT license
http://from.two2twelve.com
http://plugins.two2twelve.com

clever_validation's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.