首页 > 其他 > 详细

邮箱补全代码

时间:2016-03-26 23:48:06      阅读:310      评论:0      收藏:0      [点我收藏+]

 

$("#email").autocomplete({
delay:0,
//自动选中第一行
autoFocus:true,
source:function(request,response){

var hosts = ["qq.com","163.com","sina.com.cn","126.com","gmail.com","hotmail,com"],
term = request.term,
name = term,
host = "",
ix = term.indexOf("@"),
result=[];
//把输入的内容加进来
result.push(term);

//当有@时重新分用户名和域名

if(ix>-1){

name = term.slice(0,ix);
host = term.slice(ix+1);

}

if(name){

//如果用户输入@和后面的域名
//那么就显示提示域名
//如果还没有输入@或后面域名不存在则把所有都提示出来
var findHosts =(host ? $.grep(hosts,function(value,index){
return value.indexOf(host)>-1
}) : hosts),

findResult=$.map(findHosts,function(value,index){
return name+"@"+value;
});

result = result.concat(findResult);
}

response(result);


},

)};

邮箱补全代码

原文:http://www.cnblogs.com/baiheng/p/5324387.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!