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

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

问题描述

我想要一个自动完成/自动格式化的To字段,在我的网站上,就像在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位可以做到这一点,你可以google的jquery autocomplete看看你最喜欢哪一个。

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天全站免登陆