Solved

Struts <field-validator> for email

Posted on 2010-09-23
5
385 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

Technology Partners: 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

Suggested Solutions

Title # Comments Views Activity
java imports not found 4 71
convert Systemjs to Webpack 3 126
Programming Language for Wordpress 7 87
maximize the sum of fractions 33 76
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.
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

738 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