title: Textfield Validation in Java using LostFocus event
body: <p>I am validating two textfields using LostFocus event as follows:</p>
  
  <pre><code>textRegNo.addFocusListener(new FocusListener() {            
          @Override
          public void focusLost(FocusEvent arg0) {
              // TODO Auto-generated method stub
              regNo1=textRegNo.getText();
              Pattern pattern1 = Pattern.compile("^[A-Z]{2}[ -][0-9]{1,2}(?: [A-Z])?(?: [A-Z]*)? [0-9]{4}$");
              Matcher matcher1 = pattern1.matcher(regNo1);
  
              if (!matcher1.find()){
                  JOptionPane.showMessageDialog(null, "Invalid Vehicle No!!!\n Vehicle no should be of the form MH 03 KS 2131!!");
              }                           
          }
          @Override
          public void focusGained(FocusEvent arg0) {
              // TODO Auto-generated method stub
  
          };
      }); 
  
  
  textMobNo.addFocusListener(new FocusListener() {            
          @Override
          public void focusLost(FocusEvent arg0) {
              // TODO Auto-generated method stub
              mobNo1=textMobNo.getText();
              Pattern pattern2 = Pattern.compile("^[789]\\d{9}$");
              Matcher matcher2 = pattern2.matcher(mobNo1);
  
              System.out.println("'"+mobNo1+"'");
              if (!matcher2.find()){
                  JOptionPane.showMessageDialog(null, "Phone no must be a 10 digit number!!");
              }                           
          }
  
          @Override
          public void focusGained(FocusEvent arg0) {
              // TODO Auto-generated method stub
  
          };
      });
  </code></pre>
  
  <p>My problem is that when i lose focus on 1st textfield and move that focus to the 2nd text filed error message gets printed for both the fields(MESSAGE inside IF block under both lostfocus event.)
  When i give wrong input into 1st textfield and move focus to 2nd field it should only print the error message for 1st text field. But its printing error for both.</p>
  
  <p>1st textfield is textRegNo
  2nd textfield is textMobNo</p>