title: Validation not working in javascript
body: <p>The html is </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(":input.validate-required").on('keyup', function() {
                  $(this).closest(".form-group").removeClass("has-error");
                  $(this).next('small').addClass('hide');
              });
  
              $("#room_number").on('keyup', function() {
                  if (validateRoomNumber() == false) {
                      $(this).closest(".form-group").addClass("has-error");
                      $("#duplicate_error").removeVlass('hide');
                  }
  
              });
  
  
              function validateRoomNumber() {
                  var FloorNumber = $("#floor_number").val().trim();
                  var i;
                  for (i = 0; i &lt; arrayOfAssignedRoomNumber.length; i++) {
                      var AssignedFloorNumber = arrayOfAssignedRoomNumber[i];
                      if (AssignedFloorNumber == FloorNumber) {
                          return false;
                      }
                  }
              }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;div class="form-group required"&gt;
      &lt;label class="col-sm-3 control-label"&gt;Room Number&lt;/label&gt;
      &lt;div class="col-sm-4"&gt;
          &lt;input id="room_number" name="room_number" type="number" class="form-control validate-required" min="0" value="" /&gt;
          &lt;small id="room_number_help" class="text-danger hide"&gt;Room Number is Required&lt;/small&gt;
          &lt;small id="duplicate_error" class="text-danger hide"&gt;Room Number is Already Assigned&lt;/small&gt;
      &lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I have written below line of code for doing validation in javascript.</p>
  
  <p>Note that the below line is also useful</p>
  
  <pre><code>         $(":input.validate-required").on('keyup', function () {
              $(this).closest(".form-group").removeClass("has-error");
              $(this).next('small').addClass('hide');
          });
  </code></pre>
  
  <p>Now When user enters any already existing number, the duplicate error message does not get displayed.</p>
  
  <p>Note that the arrayOfAssignedRoomNumber contains already existing Room Numbers in database.</p>
  
  <p>Please help!!!</p>