Celebrate National Day, this year 2013 National day seven days leave no travel. To the country, to the community, to the BOOTSTRAP3 to contribute a force. 2013-10-2 bootstrap3-validation.js
JQuery plugin for BOOTSTRAP3 because a plugin has been found on the Internet is not maintained, and only support BOOTSTRAP2. Should the project require himself to write one.
ChangeLog 3.1.0.2 add basic form and inline form style. 2.1.0.1 callback Displays the information of the prompt. 2013-10-5 1. 1.0.0 creating file function Parameters
Check-type=
required cannot be empty, and in the following auto-add * number
URL represents the input URL
date date format xxxx-xx-xx
mail mailbox
number numbers, can be integer, Floating point type.
Char
Chinese Chinese
mail-message= "extended hint content", you can extend Data-message,url-message
mixlength= "6" to indicate length greater than or equal to 6
range= "2.1~3" means that the value is between [2.1~3] and check-type= "
number" range= "2.1,2,4,5" means that the value can only be filled in numbers, and Check-type = "Number"
for example:
$ ("form"). Validation (function (obj,params) {
if (obj.id== ' mail ') {
$.post ("/ Verifymail ", {mail: $ (obj). Val ()},function (data) {
params.err =!data.success;
params.msg = data.msg;}
);}
},
{reqmark:false}
);
How to use:
JS:
<script type= "Text/javascript" >
$ (function () {
//1. Simple notation:
$ ("form"). validation ();
$ ("button[type= ' Submit ']"). On (' click ', Function (event) {
//2.) finally call the valid () method.
if ($ ("form"). Valid () ==false) {
$ ("#error-text"). Text ("error!");
return false;}) })
</script>
HTML:
<form class= "Form-horizontal" action= "#" role= "form" > <div class= "Form-group" > <label for= "Mail" class= "col-sm-2 control-label" >Email</label> <div class= "col-sm-6" > <input type
= "text" class= "Form-control" id= "Mail" placeholder= "xxxx@qq.com" check-type= "Mail Required" > </div> </div> <div class= "Form-group" > <label for= "name" class= "Col-sm-2 Control-label" > User name < /label> <div class= "col-sm-6" > <input type= "text" class= "Form-control" id= "name" check-type= "Required" required-message= "please fill in your name." "> </div> </div> <div class=" Form-group "> <label for=" pw1 "class=" Col -sm-2 Control-label "> Password </label> <div class=" col-sm-6 "> <input type=" password "class=" F
Orm-control "id=" PW1 "check-type=" required "minlength=" 6 "> </div> </div><div class= "Form-group" > <label for= "pw2" class= "Col-sm-2 control-label" > Confirm password </label> &l T;div class= "col-sm-6" > <input type= "password" class= "Form-control" id= "pw2" check-type= "required" Minleng Th= "6" > </div> </div> <div class= "Form-group" > <label for= "Vercode" class= "Col-sm-2 Control-label" > Verification Code </label> <div class= "col-sm-6" > <input type= "Text" class= "Form-control" id= "Vercode" check-type= "number" range= "2.2,5" > </div> </div> & Lt;div class= "Form-group" > <div class= "col-sm-offset-2 col-sm-10" > <button type= "Submit" CLA ss= "btn btn-primary col-sm-4" > Registration </button> </div> </div> <div class= "Form-grou P "> <div class=" col-sm-offset-2 col-sm-10 "> <span id=" error-text "style=" color: #FF0000; " ></span> ≪/div> </div> </form>
BOOTSTRAP3 Validation