PDA

View Full Version : How to read from textbox and input number into script .



Bjansen
12-28-2011, 05:04 PM
* Anyone have any advice on the javascript's that grab a number from a a textbox? Need to make var plant able to read from a textbox and put the number from textbox in it.

Any help is greatly appreciated

<html>
<body>

<script type="text/javascript">
var plant = "30";

if (plant == "30"){

}

else{document.write("Please make a minnimum order of $30.00.");
}
</script>

</body>
</html>

Nile
12-28-2011, 06:25 PM
$<input type="text" name="total" id="total" />


var plant = document.getElementById("total");
plant.onchange = function(){
if(parseFloat(this.value) < 30 || isNaN(parseFloat(this.value))){
alert("Please make a minimum order of $30");
} else {
this.value = parseFloat(this.value);
}
};