title: how to minimize if-else statements while showing alerts
body: <p>I am showing <code>alerts if 3 textboxes or any single text box is empty</code>. For example:
  if <code>all are empty then alert will be" please fill up all"</code>
  <code>else if 1st and 2nd text boxes are empty then alert will be  "please fill up 1st and 2nd text box"</code>
  similarly <code>if 1st and 3rd text boxes are empty then alert will be  "please fill up 1st and 3rd text box"</code>
  similarly <code>if 2nd and 3rd text boxes are empty then alert will be  "please fill up 2nd and 3rd text box"</code>
  similarly <code>if only 1st text box is empty then alert will be  "please fill up 1st text box"</code>
  similarly <code>if only 2nd text box is empty then alert will be  "please fill up 2nd text box"</code>
  similarly <code>if only 3rd text box is empty then alert will be  "please fill up 3rd text box"</code></p>
  
  <p>But problem is i have to write so many <code>if-else statements</code> in javascript if <code>number of text boxes are 10 or more</code>. Is their any solution for this to minimize the <code>code</code> and <code>accordingly alert will come if any of the above condition satisfies</code>?</p>
  
  <p>I have written the <code>if-else code</code> individually but it is very lengthy like this:</p>
  
  <pre><code> &lt;form name="frm" action="confirmsubmit.jsp"&gt;
   &lt;script type="text/javascript"&gt;
  &lt;!--
  function confirmation() {
    var textboxname1=document.frm.textboxname1;
    var textboxname2=document.frm.textboxname2;
    var textboxname3=document.frm.textboxname3;
  
   //alert if all text boxes are empty
  
         if((textboxname1.value==null)||(textboxname1.value=="")&amp;&amp; (textboxname2.value=="")||(textboxname2.value==null)){
     alert("Please fill up first text box&lt;br/&gt;Please fill up second text box&lt;br/&gt;Please fill up 3rd text box");//alert for all
             textboxname1.focus();
             return false
         }
  
    //alert if 2nd text box is empty
  
           else if((textboxname2.value=="")||(textboxname2.value==null))
             {
   alert("Please Please fill up second text box");//alert for 2nd text box
             textboxname2.focus();
             return false 
             }              
  
     //alert if 3rd text box is empty   
  
           else if((textboxname3.value=="")||(textboxname3.value==null))
             {
   alert("Please Please fill up third text box");//alert for 3rd text box
             textboxname3.focus();
              return false 
             }  
  
            // similarly i have to show alert if 2nd and 3rd boxes are empty and so on, but is there any solution to minimize the code? 
  
              return true
  
     }
    //--&gt;
    &lt;/script&gt; 
  
  
  &lt;input type="text" name="textboxname1"/&gt;
  &lt;input type="text" name="textboxname2"/&gt;
  &lt;input type="text" name="textboxname3"/&gt;
  &lt;input type="submit" onclick="return confirmation()"/&gt; 
   &lt;/form&gt;
  </code></pre>