Skip to main content
  1. About
  2. For Teams
Asked
Viewed 116 times
-2
function checkforblank(){
  if (document.getElementById('fname').value == "help","help ","HELP","HELP ") {

    showText("#msg2", 'commands:', 0, 100);
    showText("#msg3", '#1 MAIN, back to MAIN menu', 0, 100);
    showText("#msg4", '#2 PORT, nav to PORT page', 0, 100);
    showText("#msg5", '#3 ABOUT, nav to ABOUT page', 0, 100);
    showText("#msg6", '#4 CONT, nav to CONTACT page', 0, 100);
    showText("#msg7", '#5 STOP, stop all', 0, 100);
    //(document.getElementById('textarea').document.write('jajajajajjaja'());
    return false; 
  } 
  else if (document.getElementById('fname').value == "main","main ","MAIN","MAIN "){       
    alert('hello');

  }
  else{
    alert('error');
     return false;
  }

}

my else if statement doesnt execute code but instead it does the code in the if statement..

2

1 Answer 1

0

This one doesn't work. You have to separate all different values with the OR operator ||.

if (document.getElementById('fname').value == "help" || document.getElementById('fname').value == "HELP ") {

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Post as a guest

Required, but never shown

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.