ÀûÓÃjavascriptÑéÖ¤ÊäÈë¿òÖеÄÖµÊÇ·ñΪÈÕÆÚ¸ñʽ
1¡¢ÅжÏÊÇ·ñΪÄêÔÂÈÕʱ¼ä¸ñʽ
<script>
//È¥³ý×Ö·û´®Ê×β¿Õ¸ñ
String.prototype.trim = function()
{
return this.replace(/(^\s*)|(\s*$)/g, "");
}
//ÑéÖ¤ÊÇ·ñΪÈÕÆÚ
function validator(){
if(isDate(document.all.demo1.value.trim())==false){
document.all.demo1.select();
return false;
}
}
/**
ÅжÏÊäÈë¿òÖÐÊäÈëµÄÈÕÆÚ¸ñʽÊÇ·ñΪ yyyy-mm-dd »òyyyy-m-d
*/
function isDate(dateString){
if(dateString.trim()=="")return true;
//ÄêÔÂÈÕÕýÔò±í´ïʽ
var r=dateString.match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/);
if(r==null){
alert("ÇëÊäÈë¸ñʽÕýÈ·µÄÈÕÆÚ\n\rÈÕÆÚ¸ñʽ£ºyyyy-mm-dd\n\rÀý È磺2008-08-08\n\r");
return false;
}
var d=new Date(r[1],r[3]-1,r[4]);
var num = (d.getFullYear()==r[1]&&(d.getMonth()+1)==r[3]&&d.getDate()==r[4]);
if(num==0){
alert("ÇëÊäÈë¸ñʽÕýÈ·µÄÈÕÆÚ\n\rÈÕÆÚ¸ñʽ£ºyyyy-mm-dd\n\rÀý È磺2008-08-08\n\r");
}
return (num!=0);
}
</script>
²âÊÔÊÇ·ñΪÄêÔÂÈÕʱ¼ä¸ñʽ
<input type='text' name='demo1' >
<br>
<input type='button' name='demo2' value="È·¶¨" onclick="validator()" >
ÒÔÉÏ´úÂëʵÏÖÁËÑéÖ¤ÄêÔÂÈÕ
2¡¢ÅжÏÊÇ·ñΪÄêÔÂÈÕʱ·ÖÃëʱ¼ä¸ñʽ
<script>
//È¥³ý×Ö·û´®Ê×β¿Õ¸ñ
String.prototype.trim = function()
{
return this.replace(/(^\s*)|(\s*$)/g, "");
}
//ÑéÖ¤ÊÇ·ñΪÈÕÆÚ
function validator(){
if(isDate(document.all.demo1.value.trim())==false){
document.all.demo1.select();
return fals
Ïà¹ØÎĵµ£º
Ò³ÃæÌá½»Êý¾ÝÒ»°ãÓÐÁ½ÖÖ·½·¨£ºget,post¡£post¾ÍÊÇËùνµÄformÌá½»£¬Ê¹ÓÃÊÓͼ£»getÊÇͨ¹ýurlÌá½»¡£
Get·½·¨Ò»°ãÓúǫ́´úÂ루Èçasp,asp.net£©»ñµÃ²ÎÊý£¬´úÂëºÜ¼òµ¥£ºRequest.QueryString["id"];¼´¿É»ñÈ¡¡£
ÓÐЩʱºòÐèÒªÖ±½ÓÔÚǰ̨»ñÈ¡url²ÎÊý£¬ÒªÓõ½javascript£¬jsûÓÐÖ±½Ó»ñÈ¡url²ÎÊýµÄ·½·¨£¬ÄÇô£¬ÎÒÃÇÈçºÎͨ¹ýjs ......
ÐÂÖÐ……
1¡¢Êý¾ÝÀàÐÍÑéÖ¤ÎÊÌâ
Asp.NetËäÈ»ÓÐÑéÖ¤¿Ø¼þ£¬µ«ÊÇÓÐЩ¸´ÔÓµÄÑéÖ¤»¹Êǵô«µ½·þÎñÆ÷ÉϽøÐУ¬ÓÃjsËٶȺÍÐÔÄܶ¼±È½ÏºÃ
<script>
//¼ì²éÊÇ·ñΪÈÎÒâÊý£¨ÊµÊý£©
function isNumeric(strNumber) {
var newPar=/^(-|\+)?\d+(\.\d+)?$/
alert(newPar.test(strNumber)); }
//¼ ......
1. Javascript Debug Toolkit½éÉÜ
JSDT(Javascript Debug Toolkit)ÊÇÒ»¸öÓÃÓÚjavascriptµ÷ÊÔµÄeclipse
²å¼þ£¬ÓÃÓÚµ÷ÊÔjavascript¡£JSDT¿ÉÒÔ¿çä¯ÀÀÆ÷µ÷ÊÔ£¬Ö§³ÖÔÚIE,Firefox,Safari,ChromeµÈÖ÷Á÷ä¯ÀÀÆ÷Öе÷ÊÔ
javascript¡£JSDTÖ§³ÖÉèÖöϵ㣬µ¥²½µ÷ÊԵȵ÷ÊÔ¹¤¾ßµÄ»ù±¾ÌØÐÔ¡£
2. ÈçºÎ°²×°
JSDTÊÇ»ùÓÚeclipse3.2+,jdk1.5+ ......
³ýÁËÓÃgetElementByTagName µÄÁíÒ»ÖÖ»ñÈ¡¶ÔÏ󼯺ϵķ½·¨
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" conte ......
<html>
<body>
<mce:script type="text/javascript"><!--
document.write("<table border=1px>");
for(i=1;i<=9;i++)
{document.write("<tr>");
for (j=1;j<=i;j++)
{document.write("<td class='table1'>"+i+"*"+j+"="+i*j+" & ......