dsg
Copy This
$(document).on('page:init', '.page[data-name="profile-garage-vehicle-add"]', async function (e) {
  const toggleOwnedToDatePicker = (e) => {
    const ownedToInput = document.querySelector('input[name="vehicle_owned_to"]')
    const ownedToBContainer = document.querySelector('#owned-to-block')

    const value = e.target.value

    if (value === "current") { // Current Vehicle
      ownedToBContainer.style.display = 'none'
      ownedToInput.value = ''
    } else {
      ownedToBContainer.style.display = 'block'
    }
  }

  $(document).on('change', 'select[name="vehicle_ownership"]', toggleOwnedToDatePicker)

  // input vehicle_image
  $(document).on('change', 'input[name="vehicle_image"]', function (e) {
    const file = e.target.files[0]
    const reader = new FileReader()

    reader.onload = function (e) {
      document.querySelector('.custom-file-upload label').style.backgroundImage = `url('${e.target.result}')`
      document.querySelector('.custom-file-upload label').style.backgroundSize = 'cover'
    }

    reader.readAsDataURL(file)
  })
})
Array
(
)
Add JS Function Name