title: How to validate a jtextfield to specific format?
body: <p>I need to validate a JTextField by allowing the user to input only cnic number according to this format 12345-1234567-1, i am using this regular expression but it is not worked. this is my function</p>
  
  <pre><code>private void idSearchKeyPressed(java.awt.event.KeyEvent evt) {
      String cnicValidator = idSearch.getText();
  
      if (cnicValidator.matches("^[0-9+]{5}-[0-9+]{7}-[0-9]{1}$")) {
          idSearch.setEditable(true);
      }
      else {
          idSearch.setEditable(false);
      }        
  }
  </code></pre>