Solved

Struts <field-validator> for email

Posted on 2010-09-23
5
384 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

762 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