Giter Site home page Giter Site logo

mobigo / jquery.validate.bootstrap.popover Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mingliangfeng/jquery.validate.bootstrap.popover

0.0 1.0 0.0 256 KB

Show error message via bootstrap popover for jquery validate

License: MIT License

CoffeeScript 100.00%

jquery.validate.bootstrap.popover's Introduction

jquery.validate.bootstrap.popover

Show error message via bootstrap popover for jquery validate.

Instead of calling $('#form_id').validate(), call this:

$(function() {
	$('#form_id').validate_popover();
});

Check live demo here and here.

Dependency

Options

The plugin accepts options as a single object argument. Pass in the options like this:

$('#form_id').validate_popover({ popoverPosition: 'top' });

Supported options are:

  • popoverPosition Supported values: 'right', 'top'; default to 'right'

  • popoverContainer The container popover message will append to, default: 'body'

  • hideForInvisible The flag to control if popover should be hidden for invisible validated element, default: true

  • beforeShowError A function will be called before the error popover shows, this of the function is the input html element validated:

      $('#form_id').validate_popover({ beforeShowError: function(message) { 
          alert(this.name + ": " + message); 
        }
      });
    
  • get_offset_element A function will be called when positioning error popover relative to the returned element, default implmentation is returnning the validated element. e.g. Issue 6:

      $('#form_id').validate_popover({ get_offset_element: function(element) {
          if ($(element).attr("id") == "test") {
              return $(element).siblings('.bootstrap-select');
          } else {
              return $(element);
          }
        }
      });
    

HTML data attribute options

  • data-popover-position Supported values: 'right', 'top', this will override the global setting passed to validate_popover calling.

      data-popover-position = "top"
    
  • data-popover-offset Adjust the offset of the popover message, format is "top,left", like the following example will decrease the top by 10, and increase the left by 100:

      data-popover-offset = "-10,100"
    
  • data-popover-hide-for-invisible Set to false to allow error popover is displayed even for invisible validated element:

      data-popover-hide-for-invisible="false"
    

Public Methods

Public methods could be called:

$.validator.reposition(); // re-position all popovers

Public methods list:

  • hide_validate_popover Hide the popover for a validated element:

      $.validator.hide_validate_popover($("#client_email"));
    
  • show_error Display error message programatically for an element:

      $.validator.show_error("You need to choose a template from the list.", $("#template"));
    
  • reposition Re-position all popovers when no argument is given; otherwise, only re-position popovers for given validated elements. Useful to put into window resize handler. e.g.

      $.validator.reposition($("#client_email, #client_password"));
    

License

jquery.validate.bootstrap.popover is licensed under the MIT license.

jquery.validate.bootstrap.popover's People

Contributors

asgaroth avatar mingliangfeng avatar

Watchers

 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.