Friday, August 27, 2010

validating the textfield

public void jButton1_actionPerformed(ActionEvent e) {

if( jTextField1.getText() == null || jTextField1.getText().trim().length() == 0 ||jTextField1.getText().trim().length() >20 ){

JOptionPane.showMessageDialog( null, "Name Field cannot be empty or more than 20 Characters" );

}

if ( jTextField2.getText() == null || jTextField2.getText().trim().length() == 0 || jTextField2.getText().trim().length() !=9 ){

JOptionPane.showMessageDialog( null, "Passport Field cannot be empty or not equal to 9 Characters" );

}

1 comment:

Tnx for ur comment