title: validation not appearing
body: <p>I have 2 problems. First problem is that it comes up with a notice stating roomChosen is undefined, this is a php error, and second of all, it doesn;t show a javascript error if room number in textbox does not match with a room number in database.</p>
  
  <p>Please look at the application here: <a href="http://helios.hud.ac.uk/u0867587/Mobile_app/create_session.php" rel="nofollow">application</a></p>
  
  <p>enter in 'info101' in the courseId text box and then click submit. You will see all features in the page. At bottom you will see a "Prepare Questions" button, click it and you will see all validation messages including an empty room textbox below. Now type in a room number such as 42 which is incorrext as it is not in database, if you then click on "Prepare Questions" button again, you will see not message stating room is not valid.</p>
  
  <p>Why is it not working and why am I getting a notice you will see on top?</p>
  
  <p>Below is showing the relevant code in the correct order it is displayed in:</p>
  
  <p>Javascript validation of the room textbox:</p>
  
  <pre><code>function validation() {
      var isDataValid = true;
      var roomTextO = document.getElementById("room"); 
      var errRoomMsgO = document.getElementById("roomAlert");
      if (roomTextO.value == "") {
          errRoomMsgO.innerHTML = "Please Enter in a Room Number";
          isDataValid = false;
      } else if (!trimmedRoomText.length) {
          errRoomMsgO.innerHTML = "Please Enter in a Room Number"; 
          isDataValid = false;  
  
  //above is if room textbox is empty
      } else if(roomTextO.getAttribute("roomthere") == false) {
          errRoomMsgO.innerHTML = "This Room is Invalid"; 
  //above is if room number in textbox does not match database, which at moment it isn't working
  
      } else {
          errRoomMsgO.innerHTML = ""; 
      }
      return isDataValid;
  }
  </code></pre>
  
  <p>PHP code of trying to see if value in room textbox matches value in database</p>
  
  <pre><code>&lt;?php
  $username="xxx";
  $password="xxx";
  $database="mobile_app";
  $room_there = true;
  $roomresult = mysql_query( "SELECT Room FROM Room WHERE Room = " . (int) $_POST['roomChosen']);
  if (isset($_POST['roomChosen'])) {
      $roomresult = mysql_query( "SELECT Room FROM Room WHERE Room = " . (int) $_POST['roomChosen']);
  } else {
      $room_there = false;
  }
  if( mysql_num_rows( $roomresult ) == 0 ) $room_there = false;
  ?&gt;
  </code></pre>
  
  <p>Below is Html of Room Textbox and submit button which is in a  tag</p>
  
  <pre><code>&lt;p&gt;&lt;input type="text" id="room" name="roomChosen" roomthere="&lt;?php echo $room_there; ?&gt;" /&gt;
  
  //message displayed if room number is in database or not
  &lt;br/&gt;&lt;span id="roomAlert"&gt;&lt;/span&gt;&lt;/p&gt;  
  
  // submit button 
  &lt;p&gt;&lt;input class="questionBtn" type="button" value="Prepare Questions" name="prequestion" onClick="myClickHandler()"/&gt;&lt;/p&gt;
  </code></pre>
  
  <p>Finally below is the javascript handler for the submit button after it is clicked:</p>
  
  <pre><code>function myClickHandler(){
       if(validation()){
           showConfirm(); // this is a function for a confirmation box
       }
  }
  </code></pre>
  
  <p>Below is an edit for one of the answers below on how I am using the isset:</p>
  
  <pre><code>if ($_POST['roomChosen'] [isset()]){
      $roomresult = mysql_query( "SELECT Room FROM Room WHERE Room = " . (int) $_POST['roomChosen']);
      if( mysql_num_rows( $roomresult ) == 0 ) $room_there = false;
  }
  </code></pre>