【发布时间】:2010-08-27 11:21:14
【问题描述】:
当用户在文本框中输入 @ 以输入电子邮件地址时,我想使用 jQuery 自动完成
当用户输入@afrer 输入他的电子邮件ID 域名列表时,如@gmail.com、hotmail.com、yahoo.com 应该是
填充以便用户可以选择它而不是从自动完成中键入它。
试过了还是不行
我的代码是
<!DOCTYPE html>
<html>
<head>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var autocompOpts = {
minChars:0,
matchSubset:false,
matchContains: true,
disabled: true,
source : ["@gmail.com", "@yahoo-inc.com", "@yahoo.com", "@yahoo.co.in", "@rediff.com", "@rediffmail.com", "@hotmail.com", "@msn.com", ]
};
$("input#autocomplete").autocomplete(autocompOpts);
$("input#autocomplete").bind('keyup', function(event) {
if(event.shiftKey==1)
{
if(event.keyCode==50)
{
$("input#autocomplete").autocomplete( "option", "disabled", false );
var opt = $("input#autocomplete").autocomplete( "option", "disabled");
alert(opt);
}
}
});
});
</script>
</head>
<body style="font-size:62.5%;">
<center>
<input id="autocomplete" />
</body>
</html>
【问题讨论】:
-
太多人在这里格式化!
标签: jquery email autocomplete