Plesae i need to make validation on text filed so user can insert null if user insert null on text files message box displayed to user
Asked
Active
Viewed 161 times
1 Answers
0
Get the text from the component and check if it's null? if it's null create a JOptionPane or something like that to inform the user that he didn't enter anything. Or you could use Regex's if you want to check what the user submitted.
Edit: pseudocode example
For swing components, and I'm assuming you're using a JTextField you could do something like:
if(submitbutton is triggered){
if(textField.getText().isEmpty()){
JOptionPane.showMessageDialog(component,
"You did not enter anything in the Textfield, please do so",
"Empty Textfield",
JOptionPane.PLAIN_MESSAGE);
return;
}}

Bas
- 1,232
- 1
- 12
- 26