rabal rabal - 1 year ago 68
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" >


Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download