Hi all,
I want to validate componentTextField, if these field is null or left blank and click the enter button, it must display an error message. Also need to validate the URL that is entered.
Can anyone help in this regard.
Thanks in advance.
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Hi all,
I want to validate componentTextField, if these field is null or left blank and click the enter button, it must display an error message. Also need to validate the URL that is entered.
Can anyone help in this regard.
Thanks in advance.
Last edited by HelloAll; March 1st, 2011 at 01:23 AM.
Hello,
Take a look at this code example - http://www.javaprogrammingforums.com...pressions.html
You can put the code here:
enterbutton.setText("Enter"); gridConstraints.gridx = 1; gridConstraints.gridy = 5; getContentPane().add(enterbutton, gridConstraints); enterbutton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { enterbuttonActionPerformed(e); // validate } });
You can check if something has been entered in the URLTextField by:
if(URLTextField.getText().equals("")){ //nothing has been entered } else{ //validate }
Please use [highlight=Java] code [/highlight] tags when posting your code.
Forum Tip: Add to peoples reputation by clicking the button on their useful posts.
HelloAll (February 28th, 2011)
Thanks for your help. Using Regular expression was able to validate given URL.