Reputation: 215
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;
}
Upvotes: 1
Views: 73
Reputation: 7117
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
}
Upvotes: 1
Reputation: 3584
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;
}
Hope it will be useful for you.
Upvotes: 2
Reputation: 8164
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;
}
Upvotes: 1