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 🙏

© 2025 – Pkg Stats / Ryan Hefner

palid

v0.5.2

Published

Client-Side Javascript Validation

Downloads

11

Readme

Palid

Client-Side Javascript Validation

Demo

更多实例可以参考demo,也可以直接双击运行页面docs/index.html查看效果。

特性

  1. 支持ajax、settimeout等延时验证
  2. 支持类input、select、checkbox控件的验证
  3. 支持链式验证,支持控制路径上的每一个验证节点/状态
  4. 支持自定义验证规则
  5. 支持顺序验证和同时验证

安装

npm install palid

使用

import V from 'palid'

V('input')
    .notEmpty()
    .match('integer','请输入整数')
    .done(function(s) {
        console.log(s);
    });
        
V('input[name="num"]')
    .notEmpty('num不能为空')
    .match('integer','请输入整数')
    .range(-100, 200, '#{input}不在(#{$0}~#{$1})内')
    .done('ok');

var check = V('input[name="hobbies"]')
  .notEmpty()
  .range(1, 2, '已选择#{select}个(值为#{input}),请至少选择#{$0}个,最多选择#{$1}个');
check.done('ok');

当且仅当执行done()时才进行验证

另外,还要在控件的同层插入一个class="msg"的dom,用于显示验证结果信息。

<input id="age" type="text">
<span class="msg"></span>

还可以对显示效果个性化设置

.msg.fail {
    color: #f44336;
}
.msg.ok {
    color: #4CAF50;
}