JSFiddle - React, Tailwind, and code Playground

HTML

<label class="paylabel" for="cardtype">Card Type:</label>
<select id="cardtype" name="cards">
<option value="selectcard">Please select</option>
<option value="mastercard">Mastercard</option>
<option value="maestro">Maestro</option>
<option value="solo">Solo (UK only)</option>
<option value="visaelectron">Visa Electron</option>
<option value="visadebit">Visa Debit</option>
</select>

<input type="button" onclick="fun()" value="click here">

JavaScript

//This code is only enabling the popup alert 
function fun()
{
$('#cardtype').change(function () {
  var sel = $('option:selected', this).text();
  if (sel == "Please select") {

    alert("Please select a card type");
   
  } else {

  } 
});
}