I am not very well in Java Script and i didn’t found a solution for my problem.
I have a textbox on my page where inside i am authorized to write a number between 0 and 199.
If i write 200 or >, then i want to get an alert (onblur).
I found a code who is very interesting and maybe useful.
But I don’t know if he works, because I don’t know how to implement this.
<script>
var min = 0;
var max = 199;
var num = parseInt(myform.numfield.value);
if (min > num || max < num) {
alert(num + ' is not between ' + min + ' and ' + max);
return false;
}
</script>
I Hope you can help me
Here the new code who works
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Page</title>
<script type="text/javascript">
function check(min, max) {
var num = parseInt(document.getElementById('value_one').value);
if (min > num || max < num)
{
alert(num + ' ist nicht zwischen ' + min + ' und ' + max);
}
}
</script>
</head>
<body>
<form>
Zahl: <input type='text' id='value_one' onBlur="check(0, 100)" >
</form>
</body>
</html>
I have also another question. Is it possible to add to the same function a query, where, when I write a number bigger than 99 into the same Textbox, where we have the query of MIN and MAX, to get an alert with a Message “Now we get new values”, but still when I write 200 or bigger, to get the Message like before. Is it possible? Thank you very much so late for your help. Cheers
I would put this code into a function, and then call it onblur:
and then