1.0.0 • Published 7 years ago

mvform v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

mvform

JavaScript form validation ,which is lightweight and easy.

Introduction

Rencently I need a form validation in some program having the same validate rules and style.I find parsley,which can validate the form data with same rules ,but it have different error styles and so complex.So,I decided to write a form validation to sovle the problems in these program.

Requirements

Usage

using npm

npm install mvform --save

or using bower

bower install mvform --save

Example

Setup your validation element, then invoke the function validate,finally see errors attribute ,which include all error message and element id

  var mv = Object.create(MvForm);
  mv.setup('#admin_form', {showError: true});
  var result = mv.validate();
  if (MvForm.isPrototypeOf(mv)) {
            var errors = mv.errors;
            for (var i = 0, j = errors.length; i < j; i++) {
                $('#result').append($('<p>').text('元素ID:' + errors[i].id + ';错误消息:' + errors[i].msg))
            }
        }

More examlpes to see /examples directory,introducing four way to use mvform.

Other

I use the bootstrap as css framwork.The form is horizontal,the error message will append to the label.So,bootstrap is the best choice to use with mvform.You can use mvform just as form validation ,then writing your own css style based on the mvform css style,which jsut define the error message style,see /src/mvform.css.

Contributing

I welcome contributions of all kinds from anyone.

License

Licensed under the MIT License