Multiselect ddl and textbox.
1)whenever i am selecting ddl item and put email in text box for each item manually . i want to add ',' before second email id put in text box.
2) if i am unselecting perticular item form ddl that time regarding textbox email is remove from textbox.
3) i have Email3 and Email4 hardcoded text.
function GetSelectedValue() {
debugger;
var SelectedITem = $(".selectpicker option:selected").text();
// var strUser = SelectedITem.options[SelectedITem.selectedIndex].text();
if (SelectedITem == 'Email3' || SelectedITem == 'Email4') {
txtEmailID.value = "[email protected]";
}
else {
txtEmailID.value = "";
}
}

Jayraj ChhayaRank #304 · 8.2K reputationPosted Feb 23, 2024, 1:43 AM EST
Hi Amit,
To achieve the desired functionalities, you can use JavaScript/jQuery along with ASP.NET code-behind. Here's how you can implement the required logic:
Adding a comma before the second email address:
onkeyupevent to the textbox to detect when the user enters a comma (',').$('#').on('keyup', function() { var emailAddresses = $(this).val().split(','); if (emailAddresses.length > 1) { emailAddresses[1] = ',' + emailAddresses[1].trim(); $(this).val(emailAddresses.join(',')); } });GetSelectedValuefunction to handle the removal of email addresses.function GetSelectedValue() { var selectedItems = $(".selectpicker option:selected"); var selectedText = selectedItems.text(); var txtEmailID = document.getElementById(''); if (selectedText === 'Email3' || selectedText === 'Email4') { txtEmailID.value = ""; } }