JavaScriptÕýÔò±í´ïʽ
//УÑéÊÇ·ñÈ«ÓÉÊý×Ö×é³É
function isDigit(s)
{
var patrn=/^[0-9]{1,20}$/;
if (!patrn.exec(s)) return false
return true
}
//УÑéµÇ¼Ãû£ºÖ»ÄÜÊäÈë5-20¸öÒÔ×Öĸ¿ªÍ·¡¢¿É´øÊý×Ö¡¢“_”¡¢“.”µÄ×Ö´®
function isRegisterUserName(s)
{
var patrn=/^[a-zA-Z]{1}([a-zA-Z0-9]|[._]){4,19}$/;
if (!patrn.exec(s)) return false
return true
}
//УÑéÓû§ÐÕÃû£ºÖ»ÄÜÊäÈë1-30¸öÒÔ×Öĸ¿ªÍ·µÄ×Ö´®
function isTrueName(s)
{
var patrn=/^[a-zA-Z]{1,30}$/;
if (!patrn.exec(s)) return false
return true
}
}}
//УÑéÃÜÂ룺ֻÄÜÊäÈë6-20¸ö×Öĸ¡¢Êý×Ö¡¢Ï»®Ïß
<pre name="code" class="java">function isPasswd(s)
{
var patrn=/^(\w){6,20}$/;
if (!patrn.exec(s)) return false
return true
}
</pre>
<br>
<br>//УÑéÆÕͨµç»°¡¢´«ÕæºÅÂ룺¿ÉÒÔ“+”¿ªÍ·£¬³ýÊý×ÖÍ⣬¿Éº¬ÓГ-”
<br><pre name="code" class="java">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
}
</pre>
<br>
<br>//УÑéÊÖ»úºÅÂ룺±ØÐëÒÔÊý×Ö¿ªÍ·£¬³ýÊý×ÖÍ⣬¿Éº¬ÓГ-”
<br><pre name="code" class="java">function isMobil(s)
{
var patrn=/^[+]{0,1}(\d){1,3}[ ]?([-]?((\d)|[ ]){1,12})+$/;
if (!patrn.exec(s)) return false
return true
}
</pre>
<br>
<br>//УÑéÓÊÕþ±àÂë
<br><pre name="code" class="java">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
}
</pre>
<br>
<br>//УÑéËÑË÷¹Ø¼ü×Ö
<br><pre name="code" class="java">function isSearch(s)
{
var patrn=/^[^`~!@#$%^&*()+=|\\\][\]\{\}:;'\,.<>/?]{1}[^`~!@$%^&()+=|\\\]
[\]\{\}:;'\,.<>?]{0,19}$/;
if (!patrn.exec(s)) return false
return true
}
function isIP(s) //by zergling
{
var patrn=/^[0
Ïà¹ØÎĵµ£º
ʹÓÃJavaScript¿ÉÒÔ´´½¨×Ô¼ºµÄ¶ÔÏó¡£ËäÈ»JavaScriptÄÚ²¿ºÍä¯ÀÀÆ÷±¾ÉíµÄ¹¦ÄÜÒÑÊ®·ÖÇ¿
´ó£¬µ«JavaScript»¹ÊÇÌṩÁË´´½¨Ò»¸öжÔÏóµÄ·½·¨¡£Ê¹Æä²»±ØÏñ³¬Îı¾±êʶÓïÑÔÄÇÑù£¬ÇóÓÚ»òÆäËü¶àýÌ幤¾ß£¬¾ÍÄÜÍê³ÉÐí¶à¸´ÔӵŤ×÷¡£
¡¡
¡¡ÔÚJavaScriptÖд´½¨Ò»¸öеĶÔÏóÊÇÊ®·Ö¼òµ¥µÄ¡£Ê×ÏÈËü±ØÐ붨ÒåÒ»¸ö¶ÔÏ󣬶øºóÔÙΪ¸Ã¶ÔÏó´´½¨Ò» ......
ʹÓÃä¯ÀÀÆ÷µÄÄÚ²¿¶ÔÏóϵͳ,
¿ÉʵÏÖÓëHTMLÎĵµ½øÐн»»¥¡£ËüµÄ×÷ÓÃÊǽ«Ïà¹ØÔªËØ×éÖ¯°ü×°ÆðÀ´£¬Ìṩ¸ø³ÌÐòÉè¼ÆÈËԱʹÓ㬴Ӷø¼õÇá±à³ÌÈ˵ÄÀͶ¯£¬Ìá¸ßÉè¼ÆWebÒ³ÃæµÄÄÜÁ¦¡£
Ò»¡¢
ä¯ÀÀÆ÷¶ÔÏó²ã´Î¼°ÆäÖ÷Òª×÷ÓÃ
¡¡¡¡³ýÁËÇ°ÃæÌáµ½¹ýµÄÎĵµdocument¶ÔÏóÍ⣬Navigatorä¯ÀÀÆ÷Öл¹ÌṩÁË´°¿Ú£¨Window£©¶ÔÏóÒÔ¼°ÀúÊ·£¨History£©ºÍÎ»Ö ......
JavaScriptÊÇ»ùÓÚ¶ÔÏóµÄ½Å±¾±à³ÌÓïÑÔ£¬ÄÇôËüµÄÊäÈëÊä³ö¾ÍÊÇͨ¹ý¶ÔÏóÀ´Íê³ÉµÄ¡£ÆäÖÐÓйØÊäÈë¿Éͨ
¹ý´°¿Ú£¨Window£©¶ÔÏóÀ´Íê³É£¬¶øÊä³ö¿Éͨ¹ýÎĵµ£¨document£©¶ÔÏóµÄ·½·¨À´ÊµÏÖ¡£
Ò»¡¢´°¿Ú¼°ÊäÈëÊä³ö
Çë
¿´ÏÂÃæÀý×Ó£º
<HTML>
<Head>
<script
languaga="JavaScript">
Var test=window. ......
¶¨Òå±äÁ¿
var test=10;
ʹÓöÔÏóÊôÐÔ
¿ÉÒÔʹÓà . ²Ù×÷·û»ñµÃÊôÐÔ,Ò²¿ÉÒÔʹÓÃÊý×éϱê»ñµÃ,±ÈÈç
for(var prop in document)
document.write(document[prop]+"<br>");
With ÉùÃ÷¶ÔÏó,Ö®ºóÔÙÓõ½¶ÔÏó¾Í²»±ØÉùÃ÷ÁË
with(document){
write("Hello World<br>±êÌâ: ");
write(title);
}
³£ÓöÔÏó ......
1 >ÆÁ±Î¹¦ÄÜÀà
1.1 ÆÁ±Î¼üÅÌËùÓмü
<script. language="javascript">
<!--
function document.onkeydown(){
event.keyCode = 0;
event.returnvalue = false;
}
-->
</script>
1.2 ÆÁ±ÎÊó±êÓÒ¼ü
ÔÚbody±êÇ©Àï¼ÓÉÏoncontextmenu=self.event.returnvalue=false
»òÕß
<scri ......