Я пытаюсь сделать некоторые элементы управления в Javascript при отправке формы в HTML.Контрольная сумма из полей ввода в javascript
Evertyhing отлично работает, кроме тех, которые требуют проверки суммы двух полей.
<script type="text/javascript">
function validation()
{
var count=0;
if((document.getElementsByName("people")[0].selectedIndex) == "")
{alert("How many PEOPLE?"); count++;}
else if((document.getElementsByName("amount")[0].selectedIndex) == "")
{alert("AMOUNT has to be at least 1."); count++;}
else if((document.getElementsByName("deposit")[0].value) == "")
{alert("DEPOSIT cannot be empty."); count++;}
else if((document.getElementsByName("deposit")[0].value) < "20")
{alert("DEPOSIT must be at least 20."); count++;}
else if((document.getElementsByName("topay")[0].value) == "")
{alert("Mark 0 in TO PAY if they dont have to pay more."); count++;}
else if(( (document.getElementsByName("deposit")[0].value) + (document.getElementsByName("topay")[0].value)) < "40")
{alert("The minimum price of this product is 40"); count++;}
else if((document.getElementsByName("seller")[0].value) == "")
{alert("Who is the SELLER?"); count++;}
else if(isNaN(document.getElementsByName("topay")[0].value))
{alert("TO PAY must be a number"); count++;}
else if(isNaN(document.getElementsByName("people")[0].value))
{alert("PEOPLE must be a number"); count++;}
else if(isNaN(document.getElementsByName("deposit")[0].value))
{alert("DEPOSIT must be a number"); count++;}
else if(isNaN(document.getElementsByName("amount")[0].value))
{alert("AMOUNT must be a number"); count++;}
return (count==0);
}
</script>
Тот, что я не в состоянии решить это:
else if((((document.getElementsByName("deposit")[0].value) + (document.getElementsByName("topay")[0].value)) < "40)")
{alert("The minimum price of this product is 40"); count++;}
Я хочу, чтобы проверить, если (депозит + topay) < 40. Я заметил, что с помощью этого кода это просто проверка если (депозит < 40), и я не понимаю, почему.
Не могли бы вы помочь мне?
спасибо! Он отлично работает! :) – Ame