Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

javascriptÑéÖ¤ÓÊÏä¸ñʽ´úÂë


ÓÃÒ»¸öÕý²à±í´ïʽÔÚjavascriptÖÐÑéÖ¤¾ÍÊÇ¿©!
<script language='javascript'>
function chkMail(){
if(document.form1.email.value=''){
alert("ÇëÌîдÓÊÏ䵨ַ!");
document.form1.email.focus();
return false;
}
//¿ªÊ¼ÑéÖ¤
var email = document.form1.email.value;
var pattern = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
chkFlag = pattern.test(email);
if(chkFlag){
return true;
}
else
{
alert("ÓÊÏ䵨ַµÄ¸ñʽ²»ÕýÈ·£¡");
document.form1.email.focus();
return false;
}
}
</script>
~~~~~~~~~~~~~~~~~~~~~~~Íê±Ï£¡
×î¼òµ¥µÄ¾ÍÒ»¾ä£º
if(!/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test('email'))
{
alert('email²»ÕýÈ·');
}
----------------------------------------------------------------------------------------------------------------------------
js:
function isEmail(email)
{
invalidChars = " /;,:{}[]|*%$#!()`<>?";
if (email == "")
{
return false;
}
for (i=0; i< invalidChars.length; i++)
{
badChar = invalidChars.charAt(i)
if (email.indexOf(badChar,0) > -1) {
return false;
}
}
atPos = email.indexOf("@",1)
if (atPos == -1) {   return false; }
if (email.indexOf("@", atPos+1) != -1) {   return false; }
periodPos = email.indexOf(".",atPos)
if(periodPos == -1) {
return false; // and at least one "." after the "@"
}
if ( atPos +2 > periodPos) {
return false; // and at least one character between "@" and "."
}
if ( periodPos +3 > email.length) {   return false; }
return true;
}
aspx: µ÷ÓÃ:
<input id=zz><input type=button value=check onclick="if(isEmail(zz.value))alert('ÕýÈ·');else alert('´íÎó')">


Ïà¹ØÎĵµ£º

[javascript]Ìæ»»ËùÓдø/µÄ×Ö·û´®

¼¼ÊõµÄjsµÄreplaceĬÈÏÖ»Ìæ»»µÚÒ»¸ö£¬Õâ²»ÖªµÀÄĸöÉè¼ÆµÄ£¬Èç¹ûÎÒÊÇ A / B / C / D µÄ×Ö·û´®Òª±ä³É A-B-C-D ¾ÍÒªÔÚ±»×ªÄÚÈÝʹÓúó¼Ó/g£¬ÒòΪÓÖ´øÁË/£¬¼ÓÉϸ÷¿Õ¸ñ£¬ÔÚreplace µÄµÚÒ»¸ö²ÎÊýÓ¦¸ÃÊÇ
var rut = /\/ /g;
È»ºó
replace(rut, "-"); ......

TEXTAREA ×Ö½ÚÏÞÖÆ(javascript£¬struts µÄÒ³Ãæ±êÇ©)

//Textarea maxlength
//flag:text¿òÃû×Ö£¬num:ÏÞÖÆµÄ×Ö½ÚÊý
  function maxLen(flag,num){
  if(document.getElementById('lastMessage').value=="0" || document.getElementById('lastMessage').value==flag){
    var i=document.getElementById(flag).value.replace(/[\u0 ......

JavaScript Cookie µÄÕýÈ·Ó÷¨

function getCookies(name)
{
var arr = document.cookie.match(new RegExp(&quot;(^| )&quot;+name+&quot;=([^;]*)(;|$)&quot;));
if(arr != null) return unescape(arr[2]); return &#039;&#039;;
}
function setCookie(name, value, expires,
function getCookies(name)
{
var a ......

ÉîÈëÀí½âJavaScript±Õ°ü£¨closure£©

×î½üÔÚÍøÉϲéÔÄÁ˲»ÉÙJavascript±Õ°ü(closure)Ïà¹ØµÄ×ÊÁÏ£¬Ð´µÄ´ó¶àÊǷdz£µÄѧÊõºÍרҵ¡£¶ÔÓÚ³õѧÕßÀ´Ëµ±ð˵Àí½â±Õ°üÁË£¬¾ÍÁ¬ÎÄ×ÖÐðÊö¶¼ºÜÄÑ¿´¶®¡£×«Ð´´ËÎĵÄÄ¿µÄ¾ÍÊÇÓÃ×îͨË×µÄÎÄ×Ö½Ò¿ªJavascript±Õ°üµÄÕæÊµÃæÄ¿¡£
Ò»¡¢Ê²Ã´ÊDZհü£¿
“¹Ù·½”µÄ½âÊÍÊÇ£ºËùν“±Õ°ü”£¬Ö¸µÄÊÇÒ»¸öÓµÓÐÐí¶à±äÁ¿ºÍ°ó¶¨Á ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ