1

When i entered only one email id, and check in inspecter, it shows like this

I need to remove commas,if i enter only one id and it need to show commas, if i enter one more or multiple id's given it shows comma. Can you please help ?

function GetTextValue() {

    $(divValue).empty(); 
    $(divValue).remove(); values = '';
    values += this.value + ','
    });
    document.all.contact_list.value = values;
}
rish
  • 215
  • 1
  • 2
  • 15

3 Answers3

2

You can do it like that.

function GetTextValue() {

    $(divValue).empty(); 
    $(divValue).remove(); values = '';

    $('.input').each(function() {
        divValue = $(document.createElement('div')).css({
            padding:'5px', width:'200px'
        });
        if (this.value == '') {
           // alert('Empty');
        } else if (values != '') {
            values += ',';
        }
        values += this.value;
    });
    document.all.contact_list.value = values;
}

JSFiddle

Hope it will be useful for you.

Arkar Aung
  • 3,554
  • 1
  • 16
  • 25
1
function GetTextValue() {
    $(divValue).empty();
    $(divValue).remove(); 
    var values = '';

    $('.input').each(function() {
        divValue = $(document.createElement('div')).css({
            padding:'5px', width:'200px'
        });
        if(this.value.trim() != ''){
            if(values != ''){
                values += ',';
            }
            values += this.value.trim();
        }
    });
    document.all.contact_list.value = values;
}
Jose Ricardo Bustos M.
  • 8,016
  • 6
  • 40
  • 62
1
function GetTextValue() {
    $(divValue).empty();
    $(divValue).remove(); 
    var values = '';

    $('.input').each(function() {
        divValue = $(document.createElement('div')).css({padding:'5px', width:'200px'});
       if(this.value != '') {
           values += this.value;
           values += ',';
       }
    });
    document.all.contact_list.value = value.substring(0, value.length - 1);//remove last comma
}
ozil
  • 6,930
  • 9
  • 33
  • 56