tipcss
×Ô¶¯¹¹½¨µÄÌáʾ²ãµÄÑùʽ
"left":"10px",
"top":"1px",
"height":"20px",
"width":"250px"
Ö÷ÒªÓÃÓÚ¶¨Î»×Ô¶¯¹¹½¨µÄÌáʾ²ã
forcevalid Ç¿ÖÆÊäÈëµÄÖµ±ØÐëÓÐЧ true √ ÊÇ·ñ°ÑÒ»¸öÈ«½Ç×Ö·ûµ±×ö2¸ö³¤¶ÈµÄ²ÎÊý
ajax Ìá½»·þÎñÆ÷ true √ ajaxValidatorÊÇ·ñ°Ñ¸Ã±íµ¥Ìá½»¸ø·þÎñÆ÷
defaultvalue ĬÈÏÖµ null √ ËùÓÐinputºÍselect±íµ¥¡£Èç¹ûÄã²»ÉèÖþͱ£³ÖÔÖµ£¬Ò»µ©ÉèÖþÍÉèΪĬÈÏÖµ¡£
triggerevent
ĬÈÏÖµ
blur
√
µ±Ç°Ö§³Ö2ÖÖÊôÐÔÖµ:
blur:ʧȥ½¹µãµÄʱºò´¥·¢
change:µ±ÊäÈë¿òÀïµÄÖµ·¢Éú¸Ä±äµÄʱºò´¥·¢
inputValidator£º
ÊôÐÔ ÊôÐÔÃû³Æ ĬÈÏÖµ Ïêϸ½âÊÍ
type
±È½ÏÀàÐÍ
"size"
(¶ÔselectÎÞЧ)
"size":±íʾ±È½Ï³¤¶È £¬Ä¬ÈÏÖµ
"number":ÊýÖµÐͱȽÏ
"string":×Ö·ûÐͱȽÏ
"date":¶ÌÈÕÆÚÀàÐÍ
"datetime":³¤ÈÕÆÚÀàÐÍ
min
×îС³¤¶È/Öµ
0
ĬÈÏÊýÖµÐÍ¡£Èç¹û½øÐÐ×Ö·û±È½Ï£¬ÇëÊÕÈë×Ö·ûÐÍ
¶Ôselect-one¶øÑÔinputValidatorÀïµÄ²ÎÊýminºÍmax±íʾѡÔñµÄË÷ÒýºÅ·¶Î§
¶Ôselect-multiple¶øÑÔinputValidatorÀïµÄ²ÎÊýminºÍmax±íʾѡÔñµÄ¸öÊý
max ×î´ó³¤¶È/Öµ 99999999999 ͬÉÏ
onerror ·¢Éú´íÎóµÄÌáʾ "ÊäÈë´íÎó" Ϊ¿ÕÕß²»ÏÔʾ¡£
onerrormin ±ÈminÊôÐÔСµÄÌáʾ null µ±Óû§ÊäÈëµÄÖµ±ÈminÊôÐÔСµÄʱºòµÄ´íÎóÌáʾ
onerrormax ±ÈmaxÊôÐÔ´óµÄÌáʾ null µ±Óû§ÊäÈëµÄÖµ±ÈmaxÊôÐÔ´óµÄʱºòµÄ´íÎóÌáʾ
empty
¿Ø¼þÎı¾ÖµÊÇ·ñÔÊÐíÁ½±ßΪ¿Õ
Á½±ß¶¼ÔÊÐí³öÏÖ¿Õ
ĬÈÏÖµ{leftempty:true,rightempty:true,emptyerror:null}
leftempty:±íʾ×ó±ßÊÇ·ñÔÊÐíΪ¿Õ
rightempty:±íʾÓÒ±ßÊÇ·ñÔÊÐíΪ¿Õ
emptyerror£º³öÏָôíÎóµÄʱºòµÄÌáʾ£¬Èç¹ûΪnull£¬ÔòÀûÓÃonerrorÊôÐÔÀ´Ìáʾ´íÎó¡£
compareValidator£º
ÊôÐÔ ÊôÐÔÃû³Æ ĬÈÏÖµ Ïêϸ½âÊÍ
desid Òª±È½Ï¿Ø¼þµÄID "" Òª¸úÔ´Ä¿±ê½øÐбȽϵÄÄ¿±êID
operateor ±È½Ï·ûºÅ "=" Ò»¹²ÓÐÈçϼ¸ÖÖÀàÐÍ:=¡¢!=¡¢>¡¢>=¡¢<¡¢<=
datatype Êý¾ÝÀàÐÍ "string" Ä¿Ç°Ö»Ö§³Ö2ÖÖ:"string"¡¢"number","datetime","date"
onerror ·¢Éú´íÎóµÄÌáʾ "ÊäÈë´íÎó" Ϊ¿ÕÕß²»ÏÔʾ¡£
regexValidator:
ÊôÐÔ ÊôÐÔÃû³Æ ĬÈÏÖµ Ïêϸ½âÊÍ
regexp ÕýÔò±í´ïʽ»ò±í´ïʽÊý×é "" ²ÉÓõÄÊÇÏÔʽ¹¹Ô캯Êýnew RegExp("pattern"[,"flags"]); ÓÉÓÚJavascript ÖÐ'' ±»ÓÃ×÷תÒå×Ö·û£¬ËùÒÔÔÚʹÓÃÏÔʾ¹¹Ô캯Êý¹¹ÔìʵÀý¶ÔÏóµÄʱºò£¬ÐèҪʹÓÃ'\' ´úÌæ''
param
¸½¼Ó²ÎÊý
"i"
g£º´ú±í¿ÉÒÔ½øÐÐÈ«¾ÖÆ¥Åä¡£
i£º´ú±í²»Çø·Ö´óСдƥÅä¡£
m£º´ú±í¿ÉÒÔ½øÐжàÐÐÆ¥Åä¡£
¿ÉÒÔÈÎÒâ×éºÏ,µ±È»Ò²¿ÉÒÔ²»¼Ó²ÎÊý
comparetype ±È½ÏÀàÐÍ "||" "||"»òµÄ¹Øϵ "&&"²¢ÁÐ
datatype
Êý¾ÝÀàÐÍ
"string"
"string":×Ô¼ºÐ´µÄ±í´ïʽ£¬"enum":ö¾ÙÃû¡£¾ßÌåÇë¼ûdemo3.htm
Äã¿ÉÒÔ×Ô¼ºÐ޸ġ¢Ìí¼ÓformValidatorRegex.jsÀïµÄö¾ÙÏîÄ¿ÃûºÍ±í´ïʽ¡£
onerror: ·¢Éú´íÎóµÄÌáʾ "ÊäÈë´íÎó" Ϊ¿ÕÕß²»ÏÔʾ¡£
ajaxValidator: ¼¸ºõËùÓеÄÊôÐÔ¸ú$.ajax()µÄÊôÐÔÒ»Ñù£¬Çë²Î¿¼$.ajax()º¯ÊýµÄ°ïÖú
ÊôÐÔ ÊôÐÔÃû³Æ ĬÈÏÖµ Ïêϸ½âÊÍ
type ÇëÇóµÄÀàÐÍ "GET" "POST" »ò "GET"
url ·¢Ë͵½µÄURLµØÖ· "" ÔÚ·þÎñÆ÷¶Ë£¬Äã¿ÉÒÔͨ¹ýnameΪclientid»ñÈ¡´¥·¢ÑéÖ¤µÄ¿Ø¼þIDÃû
datatype ·µ»ØµÄÊý¾ÝÀàÐÍ "html" xml¡¢html¡¢script¡¢json¡¢text
timeout ³¬Ê±ÉèÖà 999
data Êý¾Ý ""
async ÊÇ·ñÒÔÒì²½µÄ·½Ê½·¢ËÍ true
success µ±ÇëÇó³É¹¦Ê±µ÷Óõĺ¯Êý null
processdata ×Ô¶¯´¦Àí·µ»ØµÄÊý¾ÝΪ×Ö·û´® true ÔÚĬÈϵÄÇé¿öÏ£¬Èç¹ûdataÑ¡Ïî´«½øµÄÊý¾ÝÊÇÒ»¸ö¶ÔÏó¶ø²»ÊÇ×Ö·û´®£¬½«»á×Ô¶¯µØ±»´¦ÀíºÍת»»³ÉÒ»¸ö²éѯ×Ö·û´®
complete µ±ÇëÇóÍê³Éʱµ÷Óõĺ¯Êý null
beforesend µ±ÇëÇóǰʱµ÷Óõĺ¯Êý null ÓиöÒ»¸ö²ÎÊý£¬¸ù$.ajaxÀïµÄbeforeSend²ÎÊýÒ»Ñù¡£
buttons ÄãµãÌá½»µÄ°´Å¥(×é)jQuery¶ÔÏó null µ±Äã´¥·¢ÁËajaxУÑ飬buttonsÀï¶ÔÓ¦µÄ°´Å¥£¨×飩¾Í»á»Òµô£¬Ò»Ö±µÈ´ý·þÎñÆ÷·µ»ØÊý¾ÝΪֹ
error µ±ÇëÇóʧ°Üʱµ÷Óõĺ¯Êý "ÇëÇóʧ°Ü" Äã¿ÉÒÔ×Ô¼º¶¨ÒåÕâ¸ö´íÎó£¬ÔÚerrorÀï×Ô¶¯´ò³ö¡£Îª¿ÕÕß²»ÏÔʾ¡£
functionValidator
ÊôÐÔ ÊôÐÔÃû³Æ ĬÈÏÖµ ·µ»ØÖµµÄ½âÊÍ
fun
Íⲿº¯ÊýÃû()
²ÎÊý1:ÔªËصÄÖµ,
²ÎÊý2:ÔªËضÔÏó
ĬÈϵ±×÷´¦Àí¹ý³Ì
true/false УÑé³É¹¦/ʧ°Ü
×Ö·û´® УÑéʧ°Ü£¬·µ»ØÖµµ±×÷×Ô¶¨Òå´íÎó
ÎÞ ´¦Àí¹ý³Ì
onerror ·¢Éú´íÎóµÄÌáʾ "ÊäÈë´íÎó" º¯Êýreturn falseµÄʱºò£¬ÏÔʾ¸Ã´íÎóÐÅÏ¢
¹«¹²º¯Êý: Ö÷ÒªÊÇÉèÖÃÈ«¾Ö²ÎÊýºÍÅжÏÊÇ·ñͨ¹ýУÑé
º¯ÊýÃû º¯Êý˵Ã÷
$.formValidator.initConfig ²ÎÊý£ºÅäÖÃÀàÐÍ
ÊôÐÔ Ä¬ÈÏÖµ ˵Ã÷
validatorgroup "1" ÄãÒªÕë¶ÔÄĸö×é½øÐÐÅäÖÃ
formid "" Òª×Ô¶¯×¢²ápageIsValidº¯ÊýµÄ±íµ¥IDºÅ
alertmessage false ÊÇ·ñµ¯³ö´°¿Ú
autotip false ÊÇ·ñ×Ô¶¯¹¹½¨Ìáʾ²ã
errorfocus true ·¢Éú´íÎóµÄʱºò£¬µÚÒ»¸ö³ö´í¿Ø¼þÊÇ·ñ»ñµÃ½¹µã
forcevalid true ÊÇ·ñÒ»Ö±ÊäÈëÕýȷΪֹ²ÅÔÊÐíÀ뿪½¹µã
wideword true ÊÇ·ñ°ÑÒ»¸öÈ«½Ç×Ö·ûµ±×ö2¸ö³¤¶È
onsuccess null ¸Ã×éУÑéͨ¹ýºóµÄ»Øµ÷º¯Êý,·µ»Øfalse£¬×èÖ¹±íµ¥µÄÌá½»
submitonce false УÑéͨ¹ýºó£¬ÊÇ·ñ»ÒµôËùÓеÄÌá½»°´Å¥
onerror
null
¸Ã×éУÑéʧ°ÜºóµÄ»Øµ÷º¯Êý£¬ ÓÐÁ½¸ö²ÎÊý
²ÎÊý1 Ò»¸öУÑéûÓÐͨ¹ýµÄ´íÎóÐÅÏ¢
²ÎÊý2 Ò»¸öУÑéûÓÐͨ¹ýµÄÔªËضÔÏó
²ÎÊý3 ËùÓеĴíÎóÐÅÏ¢Êý×飬Äã¿ÉÒÔͨ¹ý$.mapÀ´±éÀú
debug false ÊÇ·ñ´¦ÓÚµ÷ÊÔģʽ¡£true:²»Ìá½»±íµ¥
$.formValidator.pageIsValid Ò»¸ö²ÎÊý£º ²»ÊÇÅäÖÃÀàÐÍ
validatorgroup "1" ÄãÒªÕë¶ÔÄĸö×é½øÐÐÑéÖ¤
$.formValidator.isOneValid
Ò»¸ö²ÎÊý£º µ±Ê±ÉèÖÃÑéÖ¤µÄ±íµ¥ÔªËØID¡£
·µ»ØÊÇ·ñУÑé³É¹¦µÄÐÅÏ¢¡£
$.formValidator.setFailState
function("tipid","ÏÔʾµÄÐÅÏ¢")
ÔÚshowwordģʽÏ£¬Èç¹ûÄãµÄ¶îÍâУÑéûÓÐͨ¹ý£¬Äã¿ÉÒÔͨ¹ýËüÀ´ÉèÖóÉʧ°ÜÐÅÏ¢ºÍ״̬
¡¡