1. #1
    Sencha Premium Member
    Join Date
    Mar 2011
    Location
    McKinney, TX
    Posts
    39
    Vote Rating
    0
    jbender11 is on a distinguished road

      0  

    Default Regex for Multiple emails

    Regex for Multiple emails


    I'm looking for a regular expression to parse a custom Vtype that will handle multiple email addresses. There is a lot of garbage out there on the forums that doesn't work. I'm looking for something that will allow users to enter multiple email addresses in a text field separated by either comma and/or semicolon.

    Here's what have now (that doesn't work):

    var multipleEmailValidFn = function (v) {
    var multipleEmailRegex = /^([-_a-z0-9\'+*$^&%=~!?{}]++(?:\.[-_a-z0-9\'+*$^&%=~!?{}]+)*+@(??![-.])[-a-z0-9.]+(?<![-.])\.[a-z]{2,6}|\d{1,3}(?:\.\d{1,3}){3})(?::\d++)?|,|\+$/;
    return multipleEmailRegex.test(v);
    };

    Ext.apply(Ext.form.VTypes, {
    multipleemail : multipleEmailValidFn,
    multipleemailText : 'Must be a valid email address. Use comma to separate multiple email addresses'
    });

    Any help would be appreciated.
    Sencha guys, wouldn't this be a nice addition to the Vtypes singleton?

    Thanks for your support.

  2. #2
    Sencha - Community Support Team sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,333
    Vote Rating
    85
    sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough

      1  

    Default


    Hi,
    I am defining a regex to the below textbox which can take multiple email ids separated with either comma(,) or semicolon(; ). Review the below code:

    Code:
    Ext.create('Ext.form.Panel', {
        title: 'Contact Info',
        width: 600,
        bodyPadding: 10,
        renderTo: Ext.getBody(),
        items: [{
            xtype: 'textfield',
            width: 500,
            name: 'email',
            regex: /^(([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5}){1,25})+([;,.](([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5}){1,25})+)*$/
            ,fieldLabel: 'Email',
            allowBlank: false  // requires a non-empty value
        }]
    });
    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

  3. #3
    Sencha User 123lal's Avatar
    Join Date
    Feb 2012
    Posts
    32
    Vote Rating
    0
    123lal is on a distinguished road

      0  

    Default


    Hi Developer
    Thank you,

Thread Participants: 2

Tags for this Thread