Skip to content

theqdev/mfValid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

mfValid - jQuery based form validation plugin

This is a simple yet useful plugin that aims at helping you with client side form validations.

Usage

Javascript initialisation

$(function(){
	    mfValid.init('#loginForm');
})

HTML markup and validation rules

<form id="loginForm">
   	
   <!-- mfValid Error Box -->
   <div class="mfv-errorBox"></div>
   
   <!-- mfv-checks enables the validation rules -->
   <input type="text" placeholder="Email address" name="email" mfv-checks="required:true;email:true" >
   <input type="password" placeholder="Password" name="password"  mfv-checks="required:true" >
   
   <!-- And mf-action defines the method that should be called if validation succeed -->
   <button type="submit" mfv-action="login.doLogin();">Login</button>

</form>

Validation rules and callbacks

Validation Rules:

  • required: boolean // field is required
  • min: int // minimum int value
  • max: int // maximul int value
  • email: string // check if is valid email
  • emailInDB: boolean // check if email is database
  • match: string *// match against words *

Custom functions:

  • .launchCustomError(formID, errors) // launch an mfValid error
  • .launchSuccessMessage(formID, message) // launch a success message
  • .successRedirect(page) *// redirect to page *

Note* This is still a work in progress plugin, but since it is used across couple projects, decided to add it here

About

jQuery based form validation plugin

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published