Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <input id="start-date" type="date"/>
<div id="debug-log"></div>

              
            
!

CSS

              
                
              
            
!

JS

              
                // 'blur' for test...

function logToPage(message) {
  const logContainer = document.getElementById('debug-log')
  if (logContainer) {
    const logEntry = document.createElement('div')
    logEntry.textContent = message
    logContainer.appendChild(logEntry) // Ajoute le message au conteneur
  }
}

document.addEventListener('DOMContentLoaded', () => {
  const startDateInput = document.getElementById('start-date')
  
  startDateInput.addEventListener('blur', function () {
    if (!this.value) {
      return
    }

    const selectedDate = new Date(this.value)

    if (isNaN(selectedDate.getTime())) {
      alert(`Date invalide. Veuillez réessayer.`)
      this.value = ''
      return
    }

    const day = selectedDate.getDay() // .getUTCDay()

    // Vérifiez si le jour sélectionné est un lundi
    if (day !== 1) {
      alert(`Veuillez sélectionner un lundi.`)
      this.value = ''
    } else {
      localStorage.setItem('startDate', this.value)
    }
  })
})

////////////////////////////////////////////////////////////
/*
document.addEventListener('DOMContentLoaded', () => {
  const startDateInput = document.getElementById('start-date')

  // Gestionnaire d'événement pour la date de début
  startDateInput.addEventListener('input', function () {
    if (!this.value) {
      return;
    }
    
    const selectedDate = new Date(this.value)
    
    if (isNaN(selectedDate.getTime())) {
      alert(`Date invalide. Veuillez réessayer.`)
      this.value = ''
      return
    }
    
    const day = selectedDate.getUTCDay()

    // Vérifiez si le jour sélectionné est un lundi (1 dans getDay())
    if (day !== 1) {
      alert(`Veuillez sélectionner un lundi.`)
      this.value = ''
    } else {
      localStorage.setItem('startDate', this.value)
    }
  })
})

////////////////////////////////////////////////////////

document.addEventListener('DOMContentLoaded', () => {
  const startDateInput = document.getElementById('start-date')

  // Gestionnaire d'événement pour la date de début
  startDateInput.addEventListener('input', function () {
    if (!this.value) {
      return;
    }
    
    const selectedDate = new Date(this.value)
    
    if (isNaN(selectedDate.getTime())) {
      alert(`Date invalide. Veuillez réessayer.`)
      this.value = ''
      return
    }
    
    const day = selectedDate.getUTCDay()

    // Vérifiez si le jour sélectionné est un lundi (1 dans getDay())
    if (day !== 1) {
      alert(`Veuillez sélectionner un lundi.`)
      this.value = ''
    } else {
      localStorage.setItem('startDate', this.value)
    }
  })
})

////////////////////////////////////////////////////////////////
document.addEventListener('DOMContentLoaded', () => {
  const startDateInput = document.getElementById('start-date')
  
  function isIphone() { // @bugfix Filtrage des iPhones en raison d'un bug : 0 par défaut, puis accepte la valeur 1 pour le lundi ; pas de solution pour l'instant.
    return /iPhone|iPad|iPod/i.test(navigator.userAgent)
  }

  // Gestionnaire d'événement pour la date de début
  startDateInput.addEventListener('input', function () {
    if (!this.value) {
      return
    }

    if (isIphone()) { // @todo Solution à revoir.
      return
    }

    const selectedDate = new Date(this.value)

    if (isNaN(selectedDate.getTime())) {
      alert(`Date invalide. Veuillez réessayer.`)
      this.value = ''
      return
    }

    const day = selectedDate.getUTCDay()

    // Vérifiez si le jour sélectionné est un lundi
    if (day !== 1) {
      alert(`Veuillez sélectionner un lundi.`)
      this.value = ''
    } else {
      localStorage.setItem('startDate', this.value)
    }
  })
})
*/

              
            
!
999px

Console