ÀûÓÃ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)); }
//¼ ......
The jLayout JavaScript library provides layout algorithms for laying out components. A component is an abstraction; it can be implemented in many ways, for example as items in a HTML5 Canvas drawing or as HTML elements. The jLayout library allows you to focus on drawing the individual components i ......
±¾ÎļòÒª½éÉÜJavaScriptÖÐconfirm,alert,promptµÄÓ÷¨,Ï£Íû´ó¼Òѧϰ¹ý³ÌÖÐÄܵõ½Ò»Ð©Æô·¢¡£
window.confirm ²ÎÊý¾ÍÖ»ÓÐÒ»¸ö¡£ÏÔʾÌáʾ¿òµÄÐÅÏ¢¡£°´È·¶¨,·µ»Øtrue£»°´È¡Ïû·µ»Øfalse¡£
< SCRIPT> var bln = window.confirm("È·¶¨Âð?"); alert(bln) < /SCRIPT> window.alert²ÎÊý£¬Ö»ÓÐ ......
javascriptдÔÚº¯ÊýÀïÃæ
function loadscript(url) {
document.write('<scr' + 'ipt type="text/javascript" src"' + url + '"><\/scr' + 'ipt>'>)
}
Ôڳɹ¦µÄÕýÔò±í´ïʽ²éÕÒÍê³É֮ǰ£¬ÆäÊôÐÔֵΪ undefined¡£
²»Òª½«È«¾Ö RegExp ¶ÔÏóÓë ÕýÔò±í´ïʽ
¶ÔÏó»ìÏý¡£¾¡¹ÜÌýÆðÀ´Ï ......