admin管理员组

文章数量:1418426

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

Does anyone know of such a thing for jQuery?

Plain JavaScript? Or any other alternatives?

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

Does anyone know of such a thing for jQuery?

Plain JavaScript? Or any other alternatives?

Share Improve this question edited Sep 22, 2015 at 0:48 Undo 25.7k38 gold badges112 silver badges131 bronze badges asked Oct 7, 2009 at 19:44 Zack PetersonZack Peterson 57.4k80 gold badges210 silver badges281 bronze badges 1
  • I had to remove the image from your post because ImageShack has deleted it and replaced it with advertising. See meta.stackexchange./q/263771/215468 for more information. If possible, it would be great for you to re-upload them. Thanks! – Undo Commented Sep 22, 2015 at 0:48
Add a ment  | 

3 Answers 3

Reset to default 2

http://bassistance.de/jquery-plugins/jquery-plugin-autoplete/

Check out this plugin. It appears to be quite robust and stable and may meet your needs. jQuery is a perfect choice for the kind of effect your seeking. Just keep in mind that, depending on where you want to get your data from, you'll need to create some sort of ajax/php backend.

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

Here's one that is more famous: http://docs.jquery./Plugins/AutoComplete

<script>
    var emails = [
        { name: "Kitty Sanchez", to: "[email protected]" },
        { name: "Lucille Austero", to: "[email protected]" },
        { name: "Bob Loblaw", to: "[email protected]" },
        { name: "Sally Sitwell", to: "[email protected]" }
    ];

    $(document).ready(function(){
        $("#Recipients").autoplete(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>

These answers are fine but I think he's looking for something email specific. Gmail's email auto plete is very robust and smart taking into account like who you email most often and other factors.

本文标签: javascriptjQuery Email Address InputStack Overflow