Forum Moderators: open

Message Too Old, No Replies

Validating Inputs

Validating text inputs with numbers

         

karen_pope

3:02 pm on Apr 5, 2002 (gmt 0)



Am a bit stuck with validating a text input with a set of numbers between 1 and 8. Therefore if text or any other characters are entered an alert box pops up asking them to choose a number within the specified numbers.

Could anyone help me with the javascript of this.

Thanx. Kazee

txbakers

5:08 pm on Apr 5, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



function checkthis(val) {
var ready = false;
for ( var i = 1; i <= 8; i++) {
if (val == i) {
ready = true;
break;
}
}

if (!ready) {
alert ("Not a good entry")
}

} // end function