Skip to content
/ mvform Public

JavaScript form validation ,which is lightweight and easy.

License

Notifications You must be signed in to change notification settings

snayan/mvform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

JavaScript form validation ,which is lightweight and easy.

Resources

License

Stars

Watchers

Forks

Packages

No packages published