title: How to fix it with date format?
body: <p>In this script it tries to do so that when you choose the date and the given format it shows. Of course, something is wrong with validation . If the &quot;Select date format&quot; option is selected, it will show an error. If you choose the other 2 formats, normally you should do</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var nazwamiesiecy = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
  var nazwadni = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
  
  let input = document.querySelector("input");
  let guzik = document.querySelector("button");
  
  guzik.addEventListener("click", () =&gt; {
    event.preventDefault();
  
    let wybranaData = new Date(input.value);
  
    let format = document.querySelectorAll("select").value
    let opcja1 = document.querySelectorAll("option")[0].value
    let opcja2 = document.querySelectorAll("option")[1].value
    let opcja3 = document.querySelectorAll("option")[2].value
  
    if (!input.value) {
      alert("Enter the date");
      return;
    }
  
    if (!opcja1) {
      alert("Enter the date format")
      return;
    }
  
    if (!opcja2) {
      document.getElementById("dataa").innerHTML = wybranaData.getDate() + " " + nazwamiesiecy[wybranaData.getMonth()] + " " + wybranaData.getFullYear().toString() + " roku";
      return;
    }
  
    if (!opcja3) {
      document.getElementById("dataaa").innerHTML = wybranaData.getDate() + "." + wybranaData.getMonth() + "." + wybranaData.getFullYear().toString();
      return;
    }
  })</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;form name=""&gt;
    &lt;div&gt;
      &lt;label for="txtnum1"&gt;Date: &lt;/label&gt;
      &lt;input type="date" name="txtnum1" id="txtnum1"&gt;
    &lt;/div&gt;
  
    &lt;label for="sztos"&gt;Date format: &lt;/label&gt;
    &lt;select name="sztos" id="sztos"&gt;
      &lt;option value=""&gt;Choose a date format&lt;/option&gt;
      &lt;option value="op"&gt;12/04/2000&lt;/option&gt;
      &lt;option value="xd"&gt;12 April 2000&lt;/option&gt;
    &lt;/select&gt;
  
  
    &lt;button type="submit"&gt;Calculate&lt;/button&gt;
  
    &lt;div id="dataa"&gt;&lt;/div&gt;
    &lt;div id="dataaa"&gt;&lt;/div&gt;
  &lt;/form&gt;</code></pre>
  </div>
  </div>
  </p>