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') 
}

您是否尝试将数组更改为0?

如果(结果值[0]>1000(

最新更新