Sweetalert2, могу ли я сравнить значение из диапазона ввода?

У меня есть входной диапазон от Sweetalert2, который показывает несколько значений от 50 до 4000, в этом случае я хотел бы сравнить значение, которое вводит пользователь, с уже установленным в условном выражении, чтобы код отображал предупреждение пользователю с нужные ему ценности. Код работает только до того момента, пока не подтвердит выбранную пользователем высоту.

<script>
  Swal.queue([{
  title: 'Hemoglobine/Height Simple Calculator',
  confirmButtonText: 'Next &rarr;',
  showCancelButton: true,
  text: 'what is the estimated height??',
  showLoaderOnConfirm: true,
  input: 'range',
  inputAttributes: {
    min: 50,
    max: 4000,
    step: 50
  },
  inputValue: 50,
  preConfirm: function(value) {
    Swal.insertQueueStep({
      type: 'question',
      title: 'Hemoglobine/Height Simple Calculator',
      confirmButtonText: 'Confirm',
      showCancelButton: true,
      text: 'Your value is ' + value + ' Height_above_sea_level?',
    })
  },
  allowOutsideClick: () => !Swal.isLoading()
}]).then((result) => {
  if (result.value[1] > 1000) {
    Swal.fire({
      type: 'success',
      title: 'Success!',
      text: 'The entered values ​​must be reevaluated, subtract -0.2 gr / dL from the hemoglobin values ​​for the new evaluation'
    })
  } 
  
})

if (result.value[1] > 1500) {
    Swal.fire('The entered values ​​must be reevaluated, subtract -0.5 gr / dL from the hemoglobin values ​​for the new evaluation') 
   }

person GabyMara DelValle Cordero Gmez    schedule 10.10.2020    source источник


Ответы (1)


вы пытались изменить массив на 0?

если (результат.значение[0] > 1000)

person Sergio Villalobos    schedule 15.10.2020