I am trying to write a javascript function which is called input() (performing input validation) and it will contain 3 arguments - the arguments are message, min and max.
I am having trouble bringing/writing the the function as a whole, have managed to work out bits of the function though - any help appreciated!
Code so far:
// declare variables
var min = 5
var max = 20
var message = 'input must be between 5 and 20';
// get user input
input = parseInt(prompt(message));
// check range
while(isNaN(input) || input<min || input>max) {
alert('input was invalid');
input = parseInt(prompt(message));
}
// output validation
alert('input was accepted');
(from http://jsfiddle.net/AnJym/2/)