Here is my code:
function validate() {
if (document.getElementById('check_value').value == 'this') {
$('#block').fadeIn('slow');
}
else {
alert("Nope. Try again");
}
}
I try doing this:
function validate() {
if (document.getElementById('check_value').value == 'this','that','those') {
$('#block').fadeIn('slow');
}
else {
alert("Nope. Try again");
}
}
...and it just accepts absolutely anything that's entered. Is this even possible to do?
This works too.
function validate() {
var acceptableValues = {
this: undefined,
that: undefined,
those: undefined
},
value = document.getElementById('check_value').value;
if ( acceptableValues.hasOwnProperty(value) ) {
$('#block').fadeIn('slow');
}
else {
alert("Nope. Try again");
}
}
and this:
function validate() {
var value = document.getElementById('check_value').value;
switch (value) {
case: 'this':
case: 'that':
case: 'those':
$('#block').fadeIn('slow'); break;
default:
alert("Nope. Try again");
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With