If/else condition inside an Object
<pre><code>function Validator(formIsValid) {
    if(this.formIsValid) {
        alert('Form is valid!');
    }
    else {
        alert('Form is invalid...');
    } 
}
Validator.prototype = { // Notice the .prototype here, it's important!

  formIsValid: true, 

  enforceTextFieldMinLength: function(field, minLength) {
      if (!field.value || field.value.length &lt; minLength) {
            this.formIsValid = false;
      }   
  },

  enforceLabelHasText: function(label) {
        if (!label.text) {
            this.formIsValid = false;
        }
  }
}
//var val = new Validator();
</code></pre>

<p>The above is my Val.js. This is how i am using in my otherFile.js </p>

<pre><code>AddPatient.Firstname = FirstNameValue || Validator.enforceLabelHasText(FirstName);  
</code></pre>

<p>I get an error saying <code>cannot find function enforceLabelHasText in Object function Validator(formIsValid)</code></p>
