我从Chinaren抄过来的
用了好几年了。
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;
}
用了好几年了。
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;
}
解决方案 »
- js类的constructor属性
- js函数传递的参数带有html标签要怎么处理
- jquery.validate.js 为什么用到messages 的时候IE7就跑不了 firefox却可以
- 这段动态添加的li 怎么删除自己 行为不正常????
- 大家帮忙看一下这个面试的题目
- IE里的attachEvent不好用啊, 谁来帮我改一改.
- 为什么调用file的click事件来打开客户端文件浏览器后在提交表单就报"拒绝服务“呢?
- 如何使列表框中的项目能上下移动?
- 高分奉送,select标签指定了multiple属性,用javascript怎样得到所选的每一项呢?
- 谁能给我一段做视频点播的代码在下有点急??
- 请问,javascript和其他服务器语言,比如php语言能不能相互嵌套呢?比如javascript中嵌套php.如果能,如何实现?
- 请教歌曲连播的问题
{
var re=\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*;
return re.test(s);
}