Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

335
Views
Select2: Remove duplicate inserted tags in select2 input box

I'm facing issue with select2 tags/options selection. I need to prevent duplicate option selection. enter image description here

Here is the code I'm using

$email_receiver = $(".email_receiver");
$($email_receiver).select2({
   tags: true
});
$($email_receiver).on('select2:select', function(ev) {
  var emailid = ev.params.data.id;
  if (!check_value_is_email_address(emailid)){
   $(`.email_receiver option[value="${emailid}"]`).detach();
  }
});
function check_value_is_email_address(value){
  var email_regex = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
  return email_regex.test(value);
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!