Skip to content

lmllml/zform.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

Zform.js

Zform.js is a library based on zepto.js for simplify form manipulating, and allows you to easily parse data, validate data, and submit data.Just as said, Zform.js only provide three api:

  • getData
  • validate
  • bindSubmit

In the future, there maybe more function, such as supporting async validating, more built-in validator etc.

##Zform

var form = new Zform('.form');
```
## API
### getData([options])
````javascript
var data = form.getData();

parse form data to object

validate([options])

  var isValid = form.validate({
    phone: {
      required: {
        value: 'required',
        onInvalid: function () {
          // do something
        }
      }
    },
    user: {
      pattern: /\w{3-9}/
    },
    password: {
      required: 'required'
    }
  });

validate form according to validate options

bindSubmit(options)

  form.bindSubmit({
    url: 'http://xxx.xxx.xxx',
    type: 'POST',
    success: function () {
      // do something
    },
    error: function () {
      // do something
    },
    complete: function () {
      // do something
    }
  });

bind form submit listener

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published