Working with incomplete information here...

Single input, multiple values.  I do not understand why?  There are so many 
resources available for you to permit users to enter multiple and distinct 
emails values.

The following is crude, but I think that it may be helpful....

Well as far as I know you can't use

ActionView::Helpers::FormHelper :  
http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-email_field
email_field(object_name, method, options = {}) 

>From the browser instance, you can introduce an onChange event on your 
multiple value email field with JQuery/JavaScript:

making a call to something like (just offered as psuedo code):

var my_failed_email_address = Array   // outside of the function, maybe 

function validEmail(multiple_email_element_by_id) 

     var emailRegex = 
/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
     ///  Someone can probably suggest a better reg exp 

      Use Jquery to split the multiple_email_element_by_id field value by 
your required delimiter(s) and put it into an array...

                var my_email_address = Array  // Use the above to populate 
the array
                For each element in resulting array 
                   if (!( emailRegex.test(increment value) ) )   
                       return true  // maybe just return the empty array
                  else 
                     my_failed_email_address.push(that element)  // 
Otherwise add new value to array
                    return false  //  maybe just return pupulated array
                end
              end

If this returns false, then you have numerous options: you can inform the 
user of failed email address(es) with an alert, populate some html 
span/error associated with the email input with meaningful error message, 
or change the css on the email input....

Or you can use validation in the Controller or Model in a similar fashion

In the Controller, parse the multiple email field from params and write a 
method to test for validity of each.  If failure turn to originating render
In the model, make accessible your multiple_email field, and write call 
back to parse the field for validation.  On failure, inform user at View 
level with if model.errors.any?   

Liz

On Monday, July 6, 2015 at 3:52:49 PM UTC-4, StepaAr wrote:
>
>
> <https://lh3.googleusercontent.com/-m_BZD9awBgM/VZrcgA0wDAI/AAAAAAAAAAs/trS5JfhMeQ8/s1600/trial_task.jpg>
> theoretically unlimited
>
> example picture
>
> On Monday, July 6, 2015 at 9:46:22 PM UTC+2, Elizabeth McGurty wrote:
>>
>> Predictably how many?
>>
>>
>> On Monday, July 6, 2015 at 3:04:57 PM UTC-4, StepaAr wrote:
>>>
>>> yes.
>>>
>>>
>>>
>>> On Monday, July 6, 2015 at 7:46:57 PM UTC+2, Elizabeth McGurty wrote:
>>>>
>>>> Before I respond, are you saying that in a single input you are 
>>>> gathering multiple email addresses?
>>>>
>>>>
>>>> On Monday, July 6, 2015 at 11:58:39 AM UTC-4, StepaAr wrote:
>>>>>
>>>>> I have a couple questions.
>>>>>
>>>>> 1) I have a couple of  emails.They are separated between  buy comma or 
>>>>> space.How to find which one is correct? I was thinking using regular 
>>>>> expression like this one :
>>>>>
>>>>> /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i
>>>>>
>>>>> 2)How to put valid email address  to database ?
>>>>>
>>>>> 3)If some email address is not valid then i have to give a massage using 
>>>>> client-side which email are not valid
>>>>> I was  thinking javascript.But how?I don't know to use rails and 
>>>>> javascript 
>>>>>
>>>>>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/94c5af9e-cfd1-4653-8eb9-6357e1a6ff5f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to