Skip to content

ValidForm.js is a jQuery plugin that allows form validation with help from JSON inner HTML tags

Notifications You must be signed in to change notification settings

poohia/validForm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ValidForm.js

More documentations

Author : AZOULAY Jordan

ValidForm.js is a jQuery plugin that allows form validation with help from JSON inner HTML tags


Include validForm.js :
<script src="jquery.js" ></script>
<script src="validForm.js" ></script>

Declare in html :

<form rule-form="validForm">
  ......
<form />

Or in javascript :

<script> $("#MyForm").validForm(); </script>

Declare "rules-input" into input :

<input type="text" rules-input="{active:true, regExp:'.{2,10}'}" />

Basic example :
<form rule-form="validForm">
Name* : <input  type="text" name="name"
rules-input="{active : true, regExp: '.{2,10}', addClass:'border-red'}" />
<span  class="error"></span>
<br><br>
E-mail* : <input type="text" name="email"
rules-input="{active:true, regExp:'\\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}\\b', addClass:'border-red'}" />
<br><br>
Website* : <input type="text" name="website"
rules-input="{active : true, regExp: '.{2,10}', addClass:'border-red'}">
<br><br>
Gender* :
<div  id='radioButton'>
<input type="radio" name="gender" value="female" />Female
<input type="radio" name="gender"   value="male"
rules-input="{active: true, name:'gender', errorSelector:'#radioButton > .error'}" />Male
<span class="error color-red display-none">Select one</span>
</div>
<br><br>
<div id="textArea">
Comment: <textarea name="comment" rows="5" cols="40"
rules-input="{active : true, regExp: '.{2,10}', errorSelector:'#textArea > .error',errorMsg:'Comment empty'}"></textarea>
<span class="error color-red display-none" ></span>
</div>
<br><br>
<input type="submit" name="submit" value="Submit" />
</form>

About

ValidForm.js is a jQuery plugin that allows form validation with help from JSON inner HTML tags

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published