Common error message in JavaScript
<pre><code>AddPatient = {};

AddPatient.Firstname = FirstNameValue || PatientModel.errorMsg('FirstName',FirstNameValue);
AddPatient.LastName = LastNameValue || PatientModel.errorMsg('LastName',LastNameValue);
</code></pre>

<p>AddPatient is an Object and i am checking it whether its blank or not before sending the request.       </p>

<pre><code>PatientModel.js

errorMsg: function(title,FirstNameValue,LastNameValue) {
        if(FirstNameValue === undefined || FirstNameValue === ' ' &amp;&amp; LastNameValue === undefined || LastNameValue = ' ') {
          alert('FirstName and LastName are missing');
          return false;
          } else {
          alert(+title 'is missing');
                        return false; 
          } 
        }
</code></pre>

<p>I have a form, where i have FirstName and LastName field and i have to check it should not be blank. I want a single function in javascript which can work. </p>

<p>Is this the right way to do it?</p>
