1. Introduction of files
<script src= "/js/jquery-1.4.2.min.js" type= "Text/javascript" ></script><script src= "/js/ Jqueryinline1.7/jquery.validationengine-cn.js "type=" Text/javascript "></script><script src="/js/ Jqueryinline1.7/jquery.validationengine.js "type=" Text/javascript "></script><link rel=" stylesheet " href= "/js/jqueryinline1.7/validationengine.jquery.css" type= "text/css" media= "screen" title= "no title" charset= " Utf-8 "/><link rel=" stylesheet "href="/js/jqueryinline1.7/template.css "type=" text/css "media=" screen "title=" No title "charset=" Utf-8 "/>
2. Start
Verify $ ("#form1"). Validationengine ();//Submit $ ("#submit"). Click (function () {$ ("#form1"). Submit ();});
3. Adding validation to an element
Add a
<input name= "name" type= "text" class= "validate[required" input1 ml10 "value=" <!--{$aData .name}--> ">
Add multiple
<input id= "Time" name= "Time" type= "text" class= "validate[required,custom[date]" input1 ml10 mh_date "value=" <!-- {$aData .time}--> ">
Add a custom
function Validate2fields () { if ($ ("#firstname"). val () = = "" | | $ ("#lastname"). val () = = "") { return false; } else{ return true; } }
"Validate2fields": { "nname": "Validate2fields", "Alerttext": "* You must have last name and first name"}
<input value= "" class= "validate[required,custom[onlyletter],funccall[validate2fields],length[0,100]] Text-input "type=" text "id=" LastName "Name=" LastName " />
4. Effects
Here's a look at the code of the hint
(function ($) {$.fn.validationenginelanguage = function () {}; $.validationenginelanguage = {newlang:function () {$.validationenginelanguage.allrules = {"Require D ": {//ADD your regex rules here, you can take telephone as an example" regex ":" Non E "," Alerttext ":" * Required field "," Alerttextcheckboxmultiple ":" * Please select options ", "Alerttextcheckboxe": "* requires this check box"}, "Length": {"regex": "None", "Alerttext": "* in", "AlertText2": "and", "ALERTTEXT3": "Between"} , "Maxcheckbox": {"regex": "None", "Alerttext": "* check allow more than"} , "Mincheckbox": {"regex": "None", "Alerttext": "* Please select "," alertText2 ":" Options "}," confirm": {" regex ":" None "," Alerttext ":" * your field does not match "}," Te Lephone ": {" regex ":"/^[0-9\-\ (\) \]+$/"," Alerttext ":" * Invalid Number "}, "Email": {"regex": "/^[a-za-z0-9_\.\-]+\@" ([a-za-z0-9\-]+\.) +[a-za-z0-9]{2,4}$/"," Alerttext ":" * Invalid Mailbox "}," date ": { "Regex": "/^[0-9]{4}\-\[0-9]{1,2}\-\[0-9]{1,2}$/", "Alerttext": "* Invalid date, must be YYYY-MM-DD format"}, "Onlynumber": {"regex": "/^[0-9\]+$/", "Alerttext": "* only allow numeric input "}," Nospecialcaracters ": {" regex ":"/^[0-9a-za-z]+$/", "Alerttext": "* has illegal characters"}, "Ajaxuser": {"file": "Validateuser.php", "Extradata": "Name=eric", "Alerttextok": "* This user is legal", "alerttextload": "* load, please wait", "Alertt Ext ":" * This user already exists "}," Ajaxname ": {" file ":" Validateuser.php ", "Alerttext": "* This name has been used", "Alerttextok": "* This name is OK", "alerttext Load ":" * load, please wait "}," Onlyletter ": {" regex ":"/^[a-za-z\ \ ']+$/", "Alerttext": "* only allow input of the letter"}, "Validate2fields": {"Nname": "validate2f Ields "," Alerttext ":" * you must have first and last Name "}}}) (J Query); $ (document). Ready (function () {$.validationenginelanguage.newlang ()});
Use of jquery Validationengine