jQuery的电子邮件地址输入 [英] jQuery Email Address Input

查看:297
本文介绍了jQuery的电子邮件地址输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想自动完成/自动式到在我的网站领域的作品像在Gmail中。

I'd like an autocomplete/autoformat "To" field on my web site that works like the one in GMail.

有谁知道这种事的jQuery?

Does anyone know of such a thing for jQuery?

普通的JavaScript?还是有其他的选择吗?

Plain JavaScript? Or any other alternatives?

推荐答案

有很多,很多的jQuery的比特做到这一点,你可以谷歌的jquery自动完成,看看你最喜欢的。

There are lots and lots of jquery bits that do this, you can google for "jquery autocomplete" and see which you like best.

下面是一个更出名: http://docs.jquery.com/Plugins/AutoComplete

<script>
    var emails = [
        { name: "Kitty Sanchez", to: "kanchez@bluth.com" },
        { name: "Lucille Austero", to: "lucille2@balboatowers.net" },
        { name: "Bob Loblaw", to: "bloblaw@bobloblawlawblog.com" },
        { name: "Sally Sitwell", to: "sally@sitwell.org" }
    ];

    $(document).ready(function(){
        $("#Recipients").autocomplete(emails, {
            multiple: true,
            minChars: 1,
            matchContains: "word",
            autoFill: false,
            formatItem: function(row, i, max) {
                return "\"" + row.name + "\" &lt;" + row.to + "&gt;";
            },
            formatMatch: function(row) {
                return row.name + " " + row.to;
            },
            formatResult: function(row, i, max) {
                return "\"" + row.name + "\" <" + row.to + ">";
            }
        });
    });
</script>

这篇关于jQuery的电子邮件地址输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆