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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Clear non-listed value in combo box

Thread ID:

Created:

Updated:

Platform:

Replies:

149441 Nov 26,2019 01:26 PM UTC Dec 2,2019 06:34 AM UTC Vue 3
loading
Tags: ComboBox
Masoud Moghaddari
Asked On November 26, 2019 01:26 PM UTC

Hi there,

When using combo box component in a form, if user selects an option from the drop down menu then my desired value will be set properly and the form will submit the correct value.
But if user types a new value and not select it from the drop down, the typed value will be submitted in the form.
How can I prevent that? I want only the values from the drop down list to be submitted and other values be set to null or empty for instance.

Best Regards
Masoud Moghaddari

Sevvandhi Nagulan [Syncfusion]
Replied On November 27, 2019 12:16 PM UTC

Hi Masoud 
 
Greetings from Syncfusion support. 

We have checked the reported requirement. In ComboBox allowCustom property is true by default. So if have type some value that not available in the dataSource, then it will be added to the dataSource. So we suggest disable the allowCustom value property. Kindly refer the below code, 

   <form v-on: submit="sub"> 
        <div> 
            <ejs-combobox id='dropdownlist' : dataSource='sportsData' :allowCustom ='false' ></ejs-combobox> 
        </div> 
        <div> 
            <input type="submit" id='btn' value="submit" /> 
        </div> 
        </form > 
 
  methods: { 
        sub: function(event) { 
            console.log(event.currentTarget.querySelector('input').value); 
        } 
    } 

Please find the sample and UG documentation link below, 


 
Regards, 
Sevvandhi N 


Masoud Moghaddari
Replied On November 30, 2019 05:33 AM UTC

Hi Sevvandhi,

Thank you, the solution you provided works great.

Best Regards
Masoud Moghaddari

Sevvandhi Nagulan [Syncfusion]
Replied On December 2, 2019 06:34 AM UTC

Hi Masoud, 
  
Most welcome. Please let us know if you need any other further assistance on this. 
  
Regards, 
Sevvandhi N 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon