Code Monkey home page Code Monkey logo

validator-js's Introduction

Validator-js

前端的验证工具,无其他包依赖无样式,可以适合任何环境,可根据项目环境自行组装提示信息反馈给用户。

usage:

inputselect 元素上,添加 data-validator-options 属性,然后编写json的验证器配置信息,例如:

<input id="login_name" name="login_name"
    data-validator-options="required:true,validType:['loginName','length[6,32]']" >
  • required

    代表验证必填项。

  • validType

    验证的规则组合,string 的数组,注意格式!其中 length[6,32] 的意思是,使用 length 验证规则,并且传入参数为 632

更多验证规则可自行扩展,详细使用例子:参见

在线体验: http://jsrun.net/PYiKp

Todo List

  • INPUT/SELECT元素,支持maxLength和HTML5中一些基础验证属性,requiredpattern
  • 支持minmax,这两个HTML5中对于number和date的验证属性。
  • 精炼代码,替换ES6环境。
  • 支持AMD和CMD。

validator-js's People

Contributors

kennylee26 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.