javascript ÕýÔò±í´ïʽÏê½â
function isTrueName(s) { var patrn=/^[a-zA-Z]{1,30}$/; if (!patrn.exec(s)) return false return true } }} //УÑéÃÜÂ룺ֻÄÜÊäÈë6-20¸ö×Öĸ¡¢Êý×Ö¡¢Ï»®Ïß
function isPasswd(s)
{
var patrn=/^(\w){6,20}$/;
if (!patrn.exec(s)) return false
return true
}
//УÑéÆÕͨµç»°¡¢´«ÕæºÅÂ룺¿ÉÒÔ“+”¿ªÍ·£¬³ýÊý×ÖÍ⣬¿Éº¬ÓГ-”
function isTel(s)
{
//var patrn=/^[+]{0,1}(\d){1,3}[ ]?([-]?(\d){1,12})+$/;
var patrn=/^[+]{0,1}(\d){1,3}[ ]?([-]?((\d)|[ ]){1,12})+$/;
if (!patrn.exec(s)) return false
return true
}
//УÑéÊÖ»úºÅÂ룺±ØÐëÒÔÊý×Ö¿ªÍ·£¬³ýÊý×ÖÍ⣬¿Éº¬ÓГ-”
function isMobil(s)
{
var patrn=/^[+]{0,1}(\d){1,3}[ ]?([-]?((\d)|[ ]){1,12})+$/;
if (!patrn.exec(s)) return false
return true
}
//УÑéÓÊÕþ±àÂë
function isPostalCode(s)
{
//var patrn=/^[a-zA-Z0-9]{3,12}$/;
var patrn=/^[a-zA-Z0-9 ]{3,12}$/;
if (!patrn.exec(s)) return false
return true
}
//УÑéËÑË÷¹Ø¼ü×Ö
function isSearch(s)
{
var patrn=/^[^`~!@#$%^&*()+=|\\\][\]\{\}:;'\,.<>/?]{1}[^`~!@$%^&()+=|\\\]
[\]\{\}:;'\,.<>?]{0,19}$/;
if (!patrn.exec(s)) return false
return true
}
function isIP(s) //by zergling
{
var patrn=/^[0-9.]{1,20}$/;
if (!patrn.exec(s)) return false
return true
}
ÕýÔò±í´ïʽ
"^\\d+$"¡¡¡¡//·Ç¸ºÕûÊý£¨ÕýÕûÊý + 0£©
"^[0-9]*[1-9][0-9]*$"¡¡¡¡//ÕýÕûÊý
"^((-\\d+)|(0+))$"¡¡¡¡//·ÇÕýÕûÊý£¨¸ºÕûÊý + 0£©
"^-[0-9]*[1-9][0-9]*$"¡¡¡¡//¸ºÕûÊý
"^-?\\d+$"¡¡¡¡¡¡¡¡//ÕûÊý
"^\\d+(\\.\\d+)?$"¡¡¡¡//·Ç¸º¸¡µãÊý£¨Õý¸¡µãÊý + 0£©
"^(([0-9]+\\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\\.[0-9]+)|([0-9]*[1-9][0-9]*))$"¡¡
//Õý¸¡µãÊý
"^((-\\d+(\\.\\d+)?)|(0+(\\.0+)?))$"¡¡¡¡//·ÇÕý¸¡µãÊý£¨¸º¸¡µãÊý + 0£©
"^(-(([0-9]+\\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\\.[0-9]+)|([0-9]*[1-9][0-9]*)))$"¡¡
//¸º¸¡µãÊý
"^(-?\\d+)(\\.\\d+)?$"¡¡¡¡//¸¡µãÊý
"^[A-Za-z]+$"¡¡¡¡//ÓÉ26¸öÓ¢ÎÄ×Öĸ×é³ÉµÄ×Ö·û´®
"^[A-Z]+$
Ïà¹ØÎĵµ£º
µ¥µ÷µÄÍøÕ¾Ê×Ò³±³¾°¿´¶àÁ˲»ÃâÓÐдÑá·³£¬Èç¹ûÓû§×Ô¼ºÃ¿Ë¢ÐÂÒ»´ÎÒ³Ãæ±³¾°¿ÉÒÔ¸ü»»Ò²ÐíÄÜΪÕâÖÖµ¥µ÷Ìíһ˿µÄÐÂÆæ¡£ÕâÖ»ÐèÓÃÒ»¸öJavaScript·½·¨¾Í¿ÉÒԸ㶨£¬Í¨¹ýËæ»úº¯ÊýÔÚÎÒÃǵÄÒ»×éͼƬÖÐËæ»úµÄÑ¡Ò»ÕÅ×÷Ϊ±³¾°¡£
ÏÂÃæÊÇJavaScript´úÂ룺
view plaincopy to clipboardprint?
<mce:script type="text/javascript" ......
Document¶ÔÏóÄÚÈݼ¯ºÏ
document Îĵ²¶ÔÏó - JavaScript½Å±¾ÓïÑÔÃèÊö
———————————————————————
×¢:Ò³ÃæÉÏÔªËØnameÊôÐÔºÍJavaScriptÒýÓõÄÃû³Æ±ØÐëÒ»Ö°üÀ¨´óСд
·ñ ......
·½·¨Ö÷ÒªÓÐÈýÖÖ
ת»»º¯Êý¡¢Ç¿ÖÆÀàÐÍת»»¡¢ÀûÓÃjs±äÁ¿ÈõÀàÐÍת»»¡£
1. ת»»º¯Êý
jsÌṩÁËparseInt()ºÍparseFloat()Á½¸öת»»º¯Êý¡£Ç°Õß°Ñֵת»»³ÉÕûÊý£¬ºóÕß°Ñֵת»»³É¸¡µãÊý¡£Ö»ÓжÔStringÀàÐ͵÷ÓÃÕâЩ·½·¨£¬ÕâÁ½¸öº¯Êý²ÅÄÜÕýÈ·ÔËÐУ»¶ÔÆäËûÀàÐÍ·µ»ØµÄ¶¼ÊÇNaN(Not a Number)¡£
ÔÚÅжÏ×Ö·û´®ÊÇ·ñÊÇÊý×Öֵǰ£¬parseI ......
.×Ö·û´®(String)
1.ÉùÃ÷
var myString = new String("Every good boy does fine.");
var myString = "Every good boy does fine.";
2.×Ö·û´®Á¬½Ó
var myString = "Every " + "goo ......
javascript
ʼþÁбí½â˵
ʼþ
ä¯ÀÀÆ÷Ö§³Ö
½â˵
Ò»°ãʼþ
onclick
IE3¡¢N2
Êó±êµã»÷ʱ´¥·¢´Ëʼþ
ondblclick
IE4¡¢N4
Êó±êË«»÷ʱ´¥·¢´Ëʼþ
onmousedown
IE4¡¢N4
°´ÏÂÊó±êʱ´¥·¢´Ëʼþ
onmouseup
IE4¡¢N4
Êó±ê°´ÏºóËÉ¿ªÊó±êʱ´¥·¢´Ëʼþ
onmouseover
IE3¡¢N2
µ±Êó±êÒƶ¯µ½Ä³¶ÔÏ ......