Text area entry tool that allows you to paste e-mail names and addresses from common mail clients such as Gmail, Yahoo! and Outlook. This tool will recognize the pasted input and parse out the first and last name as well as validating the e-mail address.
- Rails
- JQuery
- CoffeeScript
- Backbone.js
- Underscore.js
Add this line to your application's Gemfile:
gem 'email_name_textfield'
And then execute:
$ bundle
Add this line to your application.js file after the lines that require Backbone.js and Underscore.js:
//= require email_name_textfield
Include the css file in your application.css file:
@import "email_name_textfield";
Reference this text area by creating a new object:
myemailnamefield = new EmailNameTextField.EmailInputAreaView(placeholder: "email@address.com")
The placeholder text is simply the text that will appear by default when no e-mail addresses are shown.
Now, render this object to your view:
$("mydiv").html(myemailnamefield.render())
Emails will be immediately validated upon pasting or losing the focus on the text area.
To access the resulting list of emails and names call:
myemailnamefield.name_data()
Result will be an array of JSON objects in the format of:
{ firstName: "Mary", lastName: "Smith", email: "msmith@example.com" }
- Gmail - "Mary Smith" msmith@example.com
- Yahoo! - Mary Smith msmith@example.com
- Outlook - Smith, Mary msmith@example.com
- Hotmail - Mary Smith(msmith@example.com)
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request
