npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jquery.input-group

v1.2.1

Published

Adds validation and statuses to structured form groups, compatible with Bootstrap form groups

Downloads

224

Readme

#jquery.input-group

Adds validation and statuses to structured form groups, compatible with Bootstrap form inputs.

###Demo

install with bower bower install jquery.input-group

or npm npm install jquery.input-group

jquery.input-group needs a certain html structure minimally as follows

<group>
    <inputGroup>
        <input>
    </inputGroup>
</group>

jquery.input-group adds feedback classes and messages to this structure.

<group class="feedback-class feedback-type-class">
    <inputGroup>
        <input/>
        <feedbackIcon>
        <feedback>feedback message</feedback>
    </inputGroup>
</group>

Within this basic outline jquery.input-group aims to be as flexible as possible, allowing a wide range of structures, and is designed to work with Bootstrap form groups

<!-- twitter bootstrap form group example -->
<div class="form-group">
    <label for="inputEmail3" class="col-sm-2 control-label">Email</label>
    <div class="col-sm-10">
        <input type="text"
               name="email"
               class="form-control"
               id="inputEmail3"
               placeholder="Email">
    </div>
</div>

here is an example of the previous bootstrap form group with jquery.input-group's default error markup applied

<div class="form-group has-feedback has-error">
    <label for="inputEmail3" class="col-sm-2 control-label">Email</label>
    <div class="col-sm-10">
        <input type="text"
               name="email"
               class="form-control"
               id="inputEmail3"
               placeholder="Email">
        <span class="glyphicon glyphicon-remove form-control-feedback" aria-hidden="true">
        <span class="help-block">error message</span>
    </div>
</div>

##inputGroup error, warning, or success markup and feedback message will be applied.

$('.form-group').inputGroup({
    error: 'error message'
});

$('.form-group').inputGroup({
    warning: 'warning message'
});

$('.form-group').inputGroup({
    warning: 'warning message'
});

//if an array is passed, the message will be rendered as an unordered list.
$('.form-group').inputGroup({
    error: ['message A', 'message B']
});

inputGroup may be applied to more than one form group at once. If this is the case, then you may apply error, warning, or success markup as follows.

$('.several-form-groups').inputGroup({
    error: { foo: 'error message for input group with input named "foo"' },
    success: { bar: 'success message for input group with input named "bar"' }
});

You may also format your statuses like this.

$('.several-form-groups').inputGroup({
    foo: { error: 'error message for "foo" input' },
    bar: { success: 'success message for "bar" input' }
});

You may apply a status to a form group and omit a feedback message, by passing null for the message value.

$('.form-group').inputGroup({
    success: null
});
$('.several-form-groups').inputGroup({
    success: { foo: null, bar: null }
});

###validate inputGroup also takes a validate callback that will apply statuses on input blur

$('.form-group').inputGroup({
    validate: function (values, $blurredElement) {
        //validate should return a status object following the same format
        //detailed in the preceeding examples.
        if(!values.foo) {
            return { error: { foo: 'required' } };
        }
        else {
            return { success: { foo: null } };
        }
    }
});

###progressiveValidate inputGroup also takes a progressiveValidate` callaback that will apply statuses on input blur. Statuses will be applied progessively as a user works their way through a form. Inputs that occur after the blurred input will not be validated.

$('.form-group').inputGroup({
    progressiveValidate: function (values, $blurredElement) {
        //progressiveValidate should return a status object following the same format
        //detailed in the preceeding examples.
        if(!values.foo) {
            return { error: { foo: 'required' } };
        }
        else {
            return { success: { foo: null } };
        }
    }
});

##inputGroupClear clears the select input groups of statuses

$('.form-group').inputGroupClear();

##inputGroupValues gets the values of named inputs of selected form groups. inputGroupValues is used by the validate callback to pass validate its values. Radio input groups return the value of checked radio inputs. Checkbox input groups returns an array of values of the values of checked checkboxes.

$('.form-group').inputGroupValues();

##inputGroupConfig jquery.input-group applies status markup compatible with bootstrap by default. you may override this markup with your own custom markup.

$.inputGroupConfig({
    classes: {
        feedback: 'custom-feedback',
        error: 'custom-error',
        warning: 'custom-warning',
        success: 'custom-success'
    },

    icons: {
        error: '<div class="custom-error-icon">',
        warning: '<div class="custom-warning-icon">',
        success: '<div class="custom-success-icon">'
    },

    feedback: {
        error: '<div class="custom-error-feedback">',
        warning: '<div class="custom-warning-feedback">',
        success: '<div class="custom-success-feedback">'
    }
});