rabal rabal - 6 months ago 12
HTML Question

The value of second input type="number" cannot be exceed to the value of the first input type="number" maxlength="3"

I hope someone can help me on this. Thank you so much in advance.

this is the testing code.


<input id="first" name="first" type="number" maxlength = "3" >

<input id="second" name="second" type="number" maxlength = "3" >



If I am understanding correctly, you are not getting any errors but you are looking to do a comparison on two inputs.

You are going to have to use javascript. You will need to store each input in a variable. Then you will need to write a function to compare the values of these variables and display an output.

For example:

<button type="button" onclick="compare()">Compare!</button>


function compare()
 var firstNumber = document.getElementById("first").value;
 var secondNumber = document.getElementById("second").value;
 if(firstNumber == secondNumber)
  alert("The numbers are equal");
 else if(firstNumber > secondNumber)
  alert("The first number is larger");
  alert("The second number is larger");


Then you would put your own code in where the second number is larger based on what you want to happen.

Edit: Sorry if you wanted this in classic ASP. I'm sure you'll be able to translate it into it anyway.