Javascript Random Integer Between two Numbers
Generating random whole numbers in JavaScript in a specific range?
/**
* Returns a random number between min and max
*/
function getRandomArbitary (min, max) {
return Math.random() * (max - min) + min;
}
/**
* Returns a random integer between min and max
* Using Math.round() will give you a non-uniform distribution!
*/
function getRandomInt (min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
http://roshanbh.com.np/2008/09/get-random-number-range-two-numbers-javascript.html
//function to get random number upto m
function randomXToY(minVal,maxVal,floatVal)
{
var randVal = minVal+(Math.random()*(maxVal-minVal));
return typeof floatVal=='undefined'?Math.round(randVal):randVal.toFixed(floatVal);
}
or
Generate random number between two numbers in JavaScript
Your problem is you never converted your string to numbers try adding this
if ( numCount.match(/^[\d]*$/ ) &&
randNumMin.match(/^[\d]*$/ ) &&
randNumMax.match(/^[\d]*$/ )){
if (numCount === "" || randNumMin === "" || randNumMax === "") {
alert ("Please fill out all forms then try again.");
} else {
numCount=numCount-0;randNumMin=randNumMin-0;randNumMax=randNumMax-0;
Another note you need to change your checking if the value is an empty string to strict equality. To see what I mean try using zero for one of the values. 0 == ""//returns true
because both are falsy 0 === ""//returns false
.