I have the following code that acts as an interface to the http://www.random.org/integers/ . What I want to do is to validate all the form fields and display alert boxes or such with JavaScript. An example would be setting the numbers to be in a certain range ( in the integer case the min and max) and if they're out of range display a box saying the number has to be between 1 and 1000.
The problem that I am encountering is that the form sends me directly to the random.org website, without taking into consideration my script, it won't even display an alert box it just sends me to their website.
Here's the code.
<form method="get" action="http://www.random.org/integers/">
<p> Generate
<input type="text" name="num" value="100" size="6" maxlength="5" />
random integers (maximum 10,000).
</p>
<p>Each integer should have a value between
<input type="text" name="min" value="1" size="12" maxlength="10" /> and
<input type="text" name="max" value="100" size="12" maxlength="10" />
</p>
<p>Format in
<input type="text" name="col" value="5" size="2" maxlength="6" /> columns.
</p>
<p> Choose your base:
<select name="base">
<option value="2"> 2 </option>
<option value="8"> 8 </option>
<option value="10"> 10 </option>
</select>
</p>
<p>
<input type="submit" class="submit" value="Get Numbers" onsubmit="analert()" />
<input type="reset" class="submit" value="Reset Form" />
<input type="button" class="submit" value="Switch to Advanced Mode"/>
</p>
</form>
And the Script:
<script>
function analert()
{
alert("Tralalala");
}
</script>
How can I make this work, display an alert box that says the number is out of range, without being redirected to the random.org website which tells me that the number is out of range?