Итак, моя проблема здесь в том, что мой код, кажется, распознает, что 100 <2000, но не распознает, что 200 <1000 </p>
вот мой код (я также использую jquery в качестве основы для вашего FYI)
$('.filter-price').submit(function(e) {
var alert_message = '';
var price_from = $('.filter-price #price_from').val();
var price_to = $('.filter-price #price_to').val();
if (isNaN(price_from))
{
alert_message += "Price from must be a number, i.e. 500\n";
$('.filter-price #price_from').val('From');
}
if (isNaN(price_to))
{
alert_message += "Price to must be a number, i.e. 500\n";
$('.filter-price #price_to').val('To');
}
if (!isNaN(price_from) && !isNaN(price_to) && (price_from >= price_to))
{
alert_message += "Price from must be less than price to\n";
$('.filter-price #price_from').val('From');
$('.filter-price #price_to').val('To');
}
if (alert_message != '')
{
e.preventDefault();
alert(alert_message);
}
});
Я пытался использовать parseInt () в vars, который ничего не исправляет.