Using Javascript to compare two input numbers in HTML?

前端 未结 4 2041
没有蜡笔的小新
没有蜡笔的小新 2020-12-07 03:55

I am using Notepad++ to create a simple web page where a user types in two numbers into a text box, and then presses a button. When they press the button something comes up

4条回答
  •  無奈伤痛
    2020-12-07 04:32

    Values from inputs are retrieved as strings, you need to convert it to number. Try this:

    value1 = +document.First_num.value;
    value2 = +document.last_num.value;
    

    Also, try to be consistent when naming your input, why caps for one and lowercase for the other?

提交回复
热议问题