We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Manipulate custom values at entry time

Hi guys, I have a multiselect which allows custom entries. My use case is the user can enter an email address or select one from a predefined list. What I'd like to achieve is when the user enters a custom value, it is automatically checked against a regex to determine validity and removed if it is not. First off, I can't seem to get the customValueSelection event to fire. I can get select to respond but then I'm struggling with that removal step. 

In the code below I'm just trying to remove anything the user enters 

<ejs-multiselect id="txtTo" allowCustomValue="true" select="tochange" placeholder="To" floatLabelType="Auto" delimiterChar=";">
                            <e-multiselect-fields text="EMAIL" value="EMAIL"></e-multiselect-fields>

        function tochange(args) {

Can someone please advise what I'm doing wrong?

1 Reply

AB Ashokkumar Balasubramanian Syncfusion Team April 26, 2019 02:14 AM

Hi Jake Adams, 
Greetings from Syncfusion support. 
We were able to remove the custom value on selection in MultiSelect component. In our MultiSelect component customValueSelection event will fired only on select custom values and returned corresponding event cancel parameter. If you need to remove the invalid typed text mean, set true value for cancel (args.cancel = true) parameter in customValueSelection event. 
Also, you need to restrict the selected value for already loaded items means, we suggest use the select event and set true value for cancel parameter. If you do this in select event, corresponding value is not updated to input element. Please find the code snippet for your reference. 
<div id='multiselect' class='col-lg-6' style='padding-top:15px'> 
<ejs-multiselect id="txtTo" allowCustomValue="true" select="tochange" customValueSelection="onCustomSelection" placeholder="To" delimiterChar=";" floatLabelType="Auto"> 
<e-multiselect-fields text="EMAIL" value="EMAIL"></e-multiselect-fields> 
function onCustomSelection(args) { 
args.cancel = true; // restring the custom value selection. 
function tochange(e) { 
args.cancel = true; // restrict the select value. 
Please check the above provided code blocks and do the logic for your need in your application and update if you need any further assistance. 
Ashokkumar B. 

Live Chat Icon For mobile
Up arrow icon