JavaScript³£Ó÷½·¨×ܽᗗ¼¸¸ö±íµ¥ÑéÖ¤µÄ
¼¸¸ö±íµ¥ÑéÖ¤µÄ
function checkMail(obj,error)
{
if (obj == null)
return "NULL";
if (obj.value == "")
return "EMPTY";
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (filter.test(obj.value))
return true;
else
alert(error);
return false;
}
function verifyDottedIP(cntrl,errmsg1,errmsg2,flag)
{
ip_str = cntrl.value;
if (ip_str == "") {
if (flag == 1){
alert(errmsg1);
cntrl.select();
return false;
}
return true;
}else{
varval = 0;
vari = index = 0;
while (index < ip_str.lastIndexOf(".")){
k = index;
index = ip_str.indexOf(".", index);
val = toNumber(ip_str, k, index);
if (val < 0 || val > 255)
break;
i++; index++;
}
if (i == 3){
if (index == ip_str.length){
i = 2;
} else {
val = toNumber(ip_str,index, ip_str.length);
if (val < 0 || val > 255) i = 2;
}
}
if (i != 3) {
alert(errmsg2);
cntrl.select();
return false;
}
}
return true;
}
function verifyport(cntrl,errmsg1,errmsg2,flag)
{
varval = 0;
port_str = cntrl.value;
if (port_str == "") {
if (flag == 1){
alert(errmsg1);
cntrl.select();
return false;
}}
val = toNumber(port_str, 0, port_str.length);
if (val < 0 || val > 65535)
{
alert(errmsg2);
cntrl.select();
return false;
}
else
{
return true;
}
}
function checkname(field,err_blank,err_space,err_invalid)
{
if (field.value.indexOf(" ") >=0)
{
alert(err_space);
field.focus();
field.select();
return false;
}
left_trim(field);
right_trim(field);
if (field.value =="" | field.value == null)
{
alert(err_blank);
field.focus();
field.select();
return false;
}
if (checkOtherChar(field.value, err_invalid)==false)
{
field.focus();
field.select();
return false;
}
if (isChinese(field.value)==true)
{
field.focus();
field.select();
return false;
}
return true;
}
function isChinese(inputStr){
iLength = inputStr.length
for
Ïà¹ØÎĵµ£º
Çó 555.555µÄËÄÉáÎåÈë±£ÁôÁ½Î»Ð¡Êý
ʹÓÃMath.round Ôõô¶¼Ëã²»¶Ô,½á¹û¶¼ÊÇ555.55 ,òËÆÊÇÒòΪjava¼ÆË㸡µãÊýʱ»áĪÃûÆäÃîÔÚ½áβ¸úÉÏÒ»´®Êý×Ö ±ÈÈç555.55500000003
ÎÞÄÎÖ»ÄÜдÕâ¸ö·½·¨
function round(a,b){
var s=a.toString().indexOf(".");
a0=a.toString().substr(0,s+b+1);
a1=Math.round(a.toString().sub ......
1.document.write( " "); Êä³öÓï¾ä
2.JSÖеÄ×¢ÊÍΪ//
3.´«Í³µÄHTMLÎĵµË³ÐòÊÇ:document- >html- >(head,body)
4.Ò»¸öä¯ÀÀÆ÷´°¿ÚÖеÄDOM˳ÐòÊÇ:window- >(navigator,screen,history,location,document)
5.µÃµ½±íµ¥ÖÐÔªËصÄÃû³ÆºÍÖµ:document.getElementById( "±íµ¥ÖÐÔªËصÄID號 ").name(»òvalue)
6.Ò»¸ö ......
ÔÚJavaScriptÖпÉÒÔ´´½¨ÈýÖÖÏûÏ¢¿ò£º¾¯¸æ¿ò¡¢È·ÈÏ¿ò¡¢Ìáʾ¿ò
¾¯¸æ¿ò¾³£ÓÃÓÚÈ·±£Óû§¿ÉÒԵõ½Ä³Ð©ÐÅÏ¢¡£µ±¾¯¸æ¿ò³öÏÖºó£¬Óû§ÐèÒªµã»÷È·¶¨°´Å¥²ÅÄܼÌÐø½øÐвÙ×÷¡£
Óï·¨£º
alert("Îı¾")
È·ÈÏ¿òÓÃÓÚʹÓû§¿ÉÒÔÑéÖ¤»òÕß½ÓÊÜijЩÐÅÏ¢¡£µ±È·ÈÏ¿ò³öÏÖºó£¬Óû§ÐèÒªµã»÷È·¶¨»òÕßÈ¡Ïû°´Å¥²ÅÄܼÌÐø½øÐвÙ×÷¡£Èç¹ûÓû§µã»÷È·ÈÏ£¬Ä ......
IE¿ÉÒÔµ÷Óãº
<script type="text/javascript">
// ˵Ã÷£º»ñÈ¡Ò³ÃæÉÏÑ¡ÖеÄÎÄ×Ö
// ÕûÀí£ºhttp://www.CodeBit.cn
function getSelectedText() {
if (window.getSelection) {
// This technique is the most likel ......
<SCRIPT language=javaScript>
<!--
now = new Date(),hour = now.getHours()
if(hour < 6){document.write("Á賿ºÃ!")}
else if (hour < 9){document.write("ÔçÉϺã¡")}
else if (hour < 12){document.write("ÉÏÎçºÃ£¡")}
else if (hour < 14){document.write("ÖÐÎçºÃ£¡")}
else if (hour &l ......