javaScriptͨÓÃÊý¾ÝÀàÐÍУÑé
/**
* È¡µÃ×Ö·û´®µÄ×Ö½Ú³¤¶È
*/
´úÂë
function strlen(str)
{
var i;
var len;
len = 0;
for (i=0;i<str.length;i++)
{
if (str.charCodeAt(i)>255) len+=2; else len++;
}
return len;
}
/*
* ÅжÏÊÇ·ñΪÊý×Ö£¬ÊÇÔò·µ»Øtrue,·ñÔò·µ»Øfalse
*/
´úÂë
function f_check_number(obj)
{
if (/^\d+$/.test(obj.value))
{
return true;
}
else
{
f_alert(obj,"ÇëÊäÈëÊý×Ö");
return false;
}
}
/*
* ÅжÏÊÇ·ñΪ×ÔÈ»Êý£¬ÊÇÔò·µ»Øtrue,·ñÔò·µ»Øfalse
*/
´úÂë
function f_check_naturalnumber(obj)
{
var s = obj.value;
if (/^[0-9]+$/.test( s ) && (s > 0))
{
return true;
}
else
{
f_alert(obj,"ÇëÊäÈë×ÔÈ»Êý");
return false;
}
}
/*
* ÅжÏÊÇ·ñΪÕûÊý£¬ÊÇÔò·µ»Øtrue,·ñÔò·µ»Øfalse
*/
´úÂë
function f_check_integer(obj)
{
if (/^(\+|-)?\d+$/.test( obj.value ))
{
return true;
}
else
{
f_alert(obj,"ÇëÊäÈëÕûÊý");
return false;
}
}
/*
* ÅжÏÊÇ·ñΪʵÊý£¬ÊÇÔò·µ»Øtrue,·ñÔò·µ»Øfalse
*/
´úÂë
function f_check_float(obj)
{
if (/^(\+|-)?\d+($|\.\d+$)/.test( obj.value ))
{
return true;
}
else
{
f_alert(obj,"ÇëÊäÈëʵÊý");
return false;
}
}
/*
* УÑéÊý×ֵij¤¶ÈºÍ¾«¶È
*/
´úÂë
function f_check_double(obj){
var numReg;
var value = obj.value;
var strValueTemp, strInt, strDec;
var dtype = obj.eos_datatype;
var pos_dtype = dtype.substring(dtype.
Ïà¹ØÎĵµ£º
¡¡javascriptº¯ÊýµÄ²ÎÊýÊÇ¿ÉÑ¡µÄ¡£ËüÓÐÏÂÃ漸¸öÌص㣺
¡¡¡¡£±.ÒòΪjavascript±¾ÉíÊÇÈõÀàÐÍ£¬ËùÒÔ£¬ËüµÄº¯Êý²ÎÊýҲûÓÐÀàÐͼì²éºÍÀàÐÍÏÞ¶¨£¬Ò»Çж¼Òª¿¿±à³ÌÕß×Ô¼ºÈ¥½øÐмì²é¡£
¡¡¡¡£².²ÎÊý¸öÊý²»¶¨¡£¾¡¹ÜÄãÒ²ÔÚÔÚº¯ÊýÉùÃ÷ʱ£¬ÓУ³¸ö²ÎÊý£¬¶øÔÚʵ¼ÊµÄʹÓÃÖУ¬Äã¿ÉÒÔ´«ÈÎÒâ¸ö²ÎÊý¸øÕâ¸öº¯Êý¡£ËüµÄʶ±ð½ö½öÊÇÒÀ¿¿º¯ÊýÃû£¬ÕâÓ ......
Èç¹ûÄãÏë½øÒ»²½Á˽âÈçºÎÓÃJavaScriptÀ´ÎªÍøÒ³Ìí¼Ó½»»¥ÐԵĻ°£¬ÄãÒ²ÐíÒѾÌý¹ýJavaScriptµÄʼþ´úÀí£¨event delegation£©ÁË£¬²¢ÇÒ»á¾õµÃÖ»ÓÐÄÇЩţ±ÆºæºæµÄJavaScript³ÌÐòÔ±²Å»á¹ØÐÄÕâÑù¸´ÔÓµÄÉè¼Æģʽ¡£ÊÂʵÉÏ£¬Èç¹ûÄãÒѾ֪µÀÔõôÑùÈ¥Ìí¼ÓJavaScriptµÄʼþ´¦ÀíÆ÷£¨event handler£©£¬ÊµÏÖʼþ´úÀíÒ²ÊǼþÇá¶øÒ×¾ÙµÄÊÂÇé¡£
J ......
ÉîÈëÀí½âJavascript±Õ°ü
×î½üÔÚÍøÉϲéÔÄÁ˲»ÉÙJavascript±Õ°ü(closure)Ïà¹ØµÄ×ÊÁÏ£¬Ð´µÄ´ó¶àÊǷdz£µÄѧÊõºÍרҵ¡£¶ÔÓÚ³õѧÕßÀ´Ëµ±ð˵Àí½â±Õ°üÁË£¬¾ÍÁ¬ÎÄ×ÖÐðÊö¶¼ºÜÄÑ¿´¶®¡£×«Ð´´ËÎĵÄÄ¿µÄ¾ÍÊÇÓÃ×îͨË×µÄÎÄ×Ö½Ò¿ªJavascript±Õ°üµÄÕæʵÃæÄ¿¡£
¡¡¡¡Ò»¡¢Ê²Ã´ÊDZհü£¿
¡¡¡¡“¹Ù·½”µÄ½âÊÍÊÇ£ºËùν“±Õ°ü ......
javascript cookies²Ù×÷
<script>
//дcookiesº¯Êý ×÷ÕߣºµÔÕñ¿
function SetCookie(name,value)//Á½¸ö²ÎÊý£¬Ò»¸öÊÇcookieµÄÃû×Ó£¬Ò»¸öÊÇÖµ
{
var Days = 30; //´Ë cookie ½«±»±£´æ 30 Ìì
var exp = new Date(); //new Date("December 31, 9998");
&n ......
JavaScriptÑéÖ¤ÕýÔò±í´ïʽ´óÈ«
Æ¥ÅäÖÐÎÄ×Ö·ûµÄÕýÔò±í´ïʽ£º [\u4E00-\uFA29]
ÆÀ×¢£ºÆ¥ÅäÖÐÎÄ»¹ÕæÊǸöÍ·ÌÛµÄÊ£¬ÓÐÁËÕâ¸ö±í´ïʽ¾ÍºÃ°ìÁË
Æ¥ÅäË«×Ö½Ú×Ö·û(°üÀ¨ºº×ÖÔÚÄÚ)£º[^x00-xff]
ÆÀ×¢£º¿ÉÒÔÓÃÀ´¼ÆËã×Ö·û´®µÄ³¤¶È£¨Ò»¸öË«×Ö½Ú×Ö·û³¤¶È¼Æ2£¬ASCII×Ö·û¼Æ1£©
Æ¥Åä¿Õ°×ÐеÄÕýÔò±í´ïʽ£ºns*r
ÆÀ×¢£º¿ÉÒÔÓÃÀ´É¾³ý¿Õ°×ÐÐ
......