From 6cc2efd92548a19d143e287560d70a3b5bfa2817 Mon Sep 17 00:00:00 2001 From: Rahul Date: Thu, 18 Jul 2019 23:45:59 +0530 Subject: [PATCH] user can enter emails user can write any email in the field --- app/views/admin/emails/custom_email.html.haml | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/app/views/admin/emails/custom_email.html.haml b/app/views/admin/emails/custom_email.html.haml index cc8765ac..1ab655b5 100644 --- a/app/views/admin/emails/custom_email.html.haml +++ b/app/views/admin/emails/custom_email.html.haml @@ -7,7 +7,28 @@ .panel-body %p %b Select/Enter Emails - = text_field_tag :to, '', class: 'form-control' + = text_field_tag :to, '', class: 'form-control', id: 'admin_email_to' %br %p.text-right = link_to 'Send Email', '', class: 'btn btn-primary' + + :javascript + $(document).ready(function() { + var $select = $('#admin_email_to').selectize({ + delimiter: ',', + persist: true, + plugins: ['remove_button'], + labelField: 'item', + valueField: 'item', + sortField: 'item', + searchField: 'item', + create: function(input) { + if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(input)){ + return {} + } + return { + item: input + } + } + }) + })