Solved

Struts <field-validator> for email

Posted on 2010-09-23
5
381 Views
Last Modified: 2013-11-13
Hello,

I have attached 2 validators to validate wether the user enters or leaves the email field blank and also a validator to see if is valid or not valid from the default.xml from opensymphony.

How do I add an other validator to tell me that the email already exists?  Note: im already making a DB call and already know that the email exists... Just need the actual 3rd validator.  

Please help!!!

<field name="newCompanyAdminEmail">
        <field-validator type="requiredstring">
            <message>Please enter the admin email.</message>
        </field-validator>
        <field-validator type="email">
            <message>The email address you entered is not valid.</message>
        </field-validator>
    </field>

Open in new window

0
Comment
Question by:Squadless
  • 2
  • 2
5 Comments
 
LVL 40

Expert Comment

by:gurvinder372
ID: 33751233
<<How do I add an other validator to tell me that the email already exists?>>
but why would you want to do it, since first validator is doing exactly the same.

may be i didn't understood the requirement, can you help?
0
 
LVL 1

Author Comment

by:Squadless
ID: 33754332
sure, the first validator checks to see if the field is blank or not, the second validator checks to see if it has a @ and a . , the third validator will check to see if the email entered by the user already exists in the database.  im making the java call and know if it exists or not, but i need to catch that action using a validator not a javascript popup.
0
 
LVL 1

Author Comment

by:Squadless
ID: 33774317
HELP
0
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 300 total points
ID: 33775888
<<the third validator will check to see if the email entered by the user already exists in the database>>
for this, won't you need to make a server side request and then check for its existence? I dont think this is in the scope of struts validator.

i would suggest that you make an ajax request to check for its existence, so that user can continue to fill other fields
0
 

Assisted Solution

by:moj123456
moj123456 earned 200 total points
ID: 34109935
Depends what kind of 'validation' you want.

If you want to do client-side validation, you have no choice but Ajax.

If you want to do server-side validation, then the user will have to submit the form and consequently you can use code to validate it.

You cannot do client-side validation with simple javascript due to the fact that the userlist is lying in the DB (which the client, being a web browser on another computer, does not have access to).
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now